From 160478912af18a268c72907e6fd49bf6d95f0af2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 8 Oct 2016 23:49:29 +0200 Subject: loplugin:badstatics ScAddInListener has a member ScAddInDocs* pDocs; // documents where this is used where ScAddInDocs is set, and ScDocument has a memmber VclPtr pPrinter; so that's only a chain of (apparently non-owning) pointers. Change-Id: I050218320eb2c588dcfaee80225f4e45a515ed32 Reviewed-on: https://gerrit.libreoffice.org/29613 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- compilerplugins/clang/badstatics.cxx | 2 ++ compilerplugins/clang/check.hxx | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'compilerplugins') 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 { -- cgit