summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-14 15:49:01 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-14 18:25:49 +0200
commit36b7288a0ce9588b958e0b3a68613e9ee11cf17c (patch)
treef1a44f66b4b2bfa2d55f064b685114a01ee4723b /compilerplugins
parent9798f8ad50602cf1313a2804b86e79fb80c1ec4d (diff)
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>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx5
-rw-r--r--compilerplugins/clang/test/implicitboolconversion.cxx7
2 files changed, 9 insertions, 3 deletions
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index e61f4a14cf0f..d0bdff190807 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -180,8 +180,9 @@ bool isBoolExpr(Expr const * expr) {
TemplateDecl const * d
= t->getTemplateName().getAsTemplateDecl();
if (d == nullptr
- || (d->getQualifiedNameAsString()
- != "com::sun::star::uno::Sequence")
+ || !loplugin::DeclCheck(d->getTemplatedDecl()).Class("Sequence")
+ .Namespace("uno").Namespace("star").Namespace("sun").Namespace("com")
+ .GlobalNamespace()
|| t->getNumArgs() != 1
|| t->getArg(0).getKind() != TemplateArgument::Type)
{
diff --git a/compilerplugins/clang/test/implicitboolconversion.cxx b/compilerplugins/clang/test/implicitboolconversion.cxx
index 47c015261fef..fa5a2b84b905 100644
--- a/compilerplugins/clang/test/implicitboolconversion.cxx
+++ b/compilerplugins/clang/test/implicitboolconversion.cxx
@@ -12,6 +12,7 @@
#include <atomic>
#include <initializer_list>
+#include <com/sun/star/uno/Sequence.hxx>
#include <sal/types.h>
template <typename T> struct Sequence
@@ -35,6 +36,8 @@ template <typename T> struct Wrap2
bool g();
+void h(bool);
+
void f()
{
// expected-error@+1 {{implicit conversion (IntegralCast) from 'bool' to 'int' [loplugin:implicitboolconversion]}}
@@ -63,13 +66,15 @@ void f()
Sequence<Sequence<int>> s4{ { false } };
(void)s4;
Wrap1<sal_Bool> w1{ false };
- (void)w1;
Sequence<Wrap1<sal_Bool>> s5{ { false } };
(void)s5;
Wrap2<sal_Bool> w2{ false };
(void)w2;
Sequence<Wrap2<sal_Bool>> s6{ { false } };
(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: */