diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-04-14 23:09:41 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-04-15 08:39:21 +0200 |
commit | 6a9f342addf8b1c766163575c7b63e7fcc1f714e (patch) | |
tree | 6101583969fb87c1467d9fa2b8feb638187eae27 /compilerplugins | |
parent | d7480ed72d225ee1b2b9a6ec996eeeb7a18c98a8 (diff) |
Introduce rtl::createUriCharClass
...to make those char class array initializations more readable. (Making the
corresponding variables constexpr is mostly done so that failures in the
provided `unencoded` arguments, like non-ASCII characters or duplicate
character typos, would lead to compile-time errors also for !HAVE_CPP_CONSTEVAL.
And assigning to a sal_Bool std::array needs another hack to avoid false
loplugin:implicitboolconversion warnings.)
Change-Id: Ieb8827f69f55f1212a9428817d5331fcb18ef1d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133058
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
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: */ |