diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx index 12e6b931b3c6..db5b0dd8896c 100644 --- a/compilerplugins/clang/badstatics.cxx +++ b/compilerplugins/clang/badstatics.cxx @@ -150,6 +150,8 @@ public: // ScAddInAsync* keys if that set is not empty at exit || name == "g_aWindowList" //vcl/unx/gtk/a11y/atkutil.cxx, asserted empty at exit + || (loplugin::DeclCheck(pVarDecl).Var("aAllListeners") + .Class("ScAddInListener").GlobalNamespace()) // not owning ) // these variables appear unproblematic { return true; diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx index 0c2c1bb3031f..9bfc458354a7 100644 --- a/compilerplugins/clang/check.hxx +++ b/compilerplugins/clang/check.hxx @@ -78,6 +78,9 @@ public: ContextCheck Operator(clang::OverloadedOperatorKind op) const; + template inline ContextCheck Var(char const (& id)[N]) + const; + ContextCheck MemberFunction() const; private: @@ -198,6 +201,19 @@ template ContextCheck DeclCheck::Function(char const (& id)[N]) return ContextCheck(); } +template ContextCheck DeclCheck::Var(char const (& id)[N]) + const +{ + auto f = llvm::dyn_cast_or_null(decl_); + if (f != nullptr) { + auto const i = f->getIdentifier(); + if (i != nullptr && i->isStr(id)) { + return ContextCheck(f->getDeclContext()); + } + } + return ContextCheck(); +} + template ContextCheck ContextCheck::Namespace( char const (& id)[N]) const {