diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-05-18 08:39:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-05-18 09:30:41 +0200 |
commit | 9c3c6a6b661ea8f84c1285b07a502de5c98a1495 (patch) | |
tree | 80c0ae8b54b7df6326953e3bb2d607996a08242c /compilerplugins | |
parent | f8512cf3a8aabdba60c2994bed71c845efc6a25e (diff) |
Replace OFFSET_OF macro with a function template
(in preparation of extending loplugin:redundantcast to more reinterpret_cast
scenarios, which would have caused a false positive here). Required a tweak to
loplugin:fakebool (as the relevant reinterpret_cast to silence some occurrences
is no longer seen "inline" now), and the heuristics of loplugin:unused no longer
worked (also because of the now-hidden reinterpret_cast'ing), but adding a
maybe_unused attribute looks better than tweaking that plugin's heuristics even
further.
Change-Id: Iead1a9b31983918cf8f3b0e6c727c0081437c6d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134504
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/fakebool.cxx | 5 | ||||
-rw-r--r-- | compilerplugins/clang/test/fakebool.cxx | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/compilerplugins/clang/fakebool.cxx b/compilerplugins/clang/fakebool.cxx index 80efa55bd432..cc7a9434a69e 100644 --- a/compilerplugins/clang/fakebool.cxx +++ b/compilerplugins/clang/fakebool.cxx @@ -451,9 +451,10 @@ bool FakeBool::VisitUnaryOperator(UnaryOperator * op) { Expr const * e1 = op->getSubExpr()->IgnoreParenCasts(); if (isFakeBool(e1->getType()) != FBK_No) { if (DeclRefExpr const * e2 = dyn_cast<DeclRefExpr>(e1)) { - VarDecl const * d = dyn_cast<VarDecl>(e2->getDecl()); - if (d != nullptr) { + if (auto const d = dyn_cast<VarDecl>(e2->getDecl())) { varDecls_.erase(d); + } else if (auto const d = dyn_cast<FieldDecl>(e2->getDecl())) { + fieldDecls_.erase(d); } } else if (auto const e3 = dyn_cast<MemberExpr>(e1)) { if (auto const d = dyn_cast<FieldDecl>(e3->getMemberDecl())) { diff --git a/compilerplugins/clang/test/fakebool.cxx b/compilerplugins/clang/test/fakebool.cxx index 936e970e5e85..144bf4a28a15 100644 --- a/compilerplugins/clang/test/fakebool.cxx +++ b/compilerplugins/clang/test/fakebool.cxx @@ -33,4 +33,18 @@ struct S3 { void f() { S2 s(b_); } }; +namespace { + +struct S4 { + sal_Bool b; +}; + +} + +void f() { + sal_Bool b; + (void) &b; + (void) &S4::b; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |