diff options
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/implicitboolconversion.cxx | 21 | ||||
-rw-r--r-- | compilerplugins/clang/test/implicitboolconversion.cxx | 3 |
2 files changed, 17 insertions, 7 deletions
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index d0bdff190807..29b82d8eae25 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -179,16 +179,23 @@ bool isBoolExpr(Expr const * expr) { (void)op; TemplateDecl const * d = t->getTemplateName().getAsTemplateDecl(); - if (d == nullptr - || !loplugin::DeclCheck(d->getTemplatedDecl()).Class("Sequence") - .Namespace("uno").Namespace("star").Namespace("sun").Namespace("com") - .GlobalNamespace() - || t->getNumArgs() != 1 - || t->getArg(0).getKind() != TemplateArgument::Type) + if (d == nullptr) { + break; + } + auto const dc = loplugin::DeclCheck(d->getTemplatedDecl()); + if (dc.ClassOrStruct("array").StdNamespace() && t->getNumArgs() >= 2 + && t->getArg(0).getKind() == TemplateArgument::Type) { + ty = t->getArg(0).getAsType(); + } else if (dc.Class("Sequence").Namespace("uno").Namespace("star").Namespace("sun") + .Namespace("com").GlobalNamespace() + && t->getNumArgs() == 1 + && t->getArg(0).getKind() == TemplateArgument::Type) + { + ty = t->getArg(0).getAsType(); + } else { break; } - ty = t->getArg(0).getAsType(); } stack.pop(); if (stack.empty()) { diff --git a/compilerplugins/clang/test/implicitboolconversion.cxx b/compilerplugins/clang/test/implicitboolconversion.cxx index fa5a2b84b905..122ee363ae68 100644 --- a/compilerplugins/clang/test/implicitboolconversion.cxx +++ b/compilerplugins/clang/test/implicitboolconversion.cxx @@ -9,6 +9,7 @@ #include <sal/config.h> +#include <array> #include <atomic> #include <initializer_list> @@ -75,6 +76,8 @@ void f() h(w1.element); css::uno::Sequence<sal_Bool> s7(1); h(s7[0]); + std::array<sal_Bool, 1> s8; + s8[0] = false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |