Use DeclCheck at one place in loplugin:implicitboolconversion
...and add tests for those additions to isBoolExpr done in 8e4d82cd1125502c26ddaaa85c49c4aa44f65811 "loplugin:implicitboolconversion: warn about conversions to unsigned char" (and which were added to avoid false warnings like > testtools/source/bridgetest/bridgetest.cxx:643:21: error: implicit conversion (IntegralToBoolean) of call argument from 'unsigned char' to 'bool' [loplugin:implicitboolconversion] > (xLBT->transportPolyBoolean( > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ and > cui/source/options/optaboutconfig.cxx:359:62: error: implicit conversion (IntegralToBoolean) of call argument from 'unsigned char' to 'bool' [loplugin:implicitboolconversion] > sValue.append(OUString::boolean( seq[j] )); > ^~~~~~ ) Change-Id: I0683144e1c39d31303faf678afaafd708ef7ff79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133018 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
9798f8ad50
commit
36b7288a0c
@ -180,8 +180,9 @@ bool isBoolExpr(Expr const * expr) {
|
|||||||
TemplateDecl const * d
|
TemplateDecl const * d
|
||||||
= t->getTemplateName().getAsTemplateDecl();
|
= t->getTemplateName().getAsTemplateDecl();
|
||||||
if (d == nullptr
|
if (d == nullptr
|
||||||
|| (d->getQualifiedNameAsString()
|
|| !loplugin::DeclCheck(d->getTemplatedDecl()).Class("Sequence")
|
||||||
!= "com::sun::star::uno::Sequence")
|
.Namespace("uno").Namespace("star").Namespace("sun").Namespace("com")
|
||||||
|
.GlobalNamespace()
|
||||||
|| t->getNumArgs() != 1
|
|| t->getNumArgs() != 1
|
||||||
|| t->getArg(0).getKind() != TemplateArgument::Type)
|
|| t->getArg(0).getKind() != TemplateArgument::Type)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
#include <sal/types.h>
|
#include <sal/types.h>
|
||||||
|
|
||||||
template <typename T> struct Sequence
|
template <typename T> struct Sequence
|
||||||
@ -35,6 +36,8 @@ template <typename T> struct Wrap2
|
|||||||
|
|
||||||
bool g();
|
bool g();
|
||||||
|
|
||||||
|
void h(bool);
|
||||||
|
|
||||||
void f()
|
void f()
|
||||||
{
|
{
|
||||||
// expected-error@+1 {{implicit conversion (IntegralCast) from 'bool' to 'int' [loplugin:implicitboolconversion]}}
|
// expected-error@+1 {{implicit conversion (IntegralCast) from 'bool' to 'int' [loplugin:implicitboolconversion]}}
|
||||||
@ -63,13 +66,15 @@ void f()
|
|||||||
Sequence<Sequence<int>> s4{ { false } };
|
Sequence<Sequence<int>> s4{ { false } };
|
||||||
(void)s4;
|
(void)s4;
|
||||||
Wrap1<sal_Bool> w1{ false };
|
Wrap1<sal_Bool> w1{ false };
|
||||||
(void)w1;
|
|
||||||
Sequence<Wrap1<sal_Bool>> s5{ { false } };
|
Sequence<Wrap1<sal_Bool>> s5{ { false } };
|
||||||
(void)s5;
|
(void)s5;
|
||||||
Wrap2<sal_Bool> w2{ false };
|
Wrap2<sal_Bool> w2{ false };
|
||||||
(void)w2;
|
(void)w2;
|
||||||
Sequence<Wrap2<sal_Bool>> s6{ { false } };
|
Sequence<Wrap2<sal_Bool>> s6{ { false } };
|
||||||
(void)s6;
|
(void)s6;
|
||||||
|
h(w1.element);
|
||||||
|
css::uno::Sequence<sal_Bool> s7(1);
|
||||||
|
h(s7[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user