diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-08 23:49:29 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-09 07:40:09 +0000 |
commit | 160478912af18a268c72907e6fd49bf6d95f0af2 (patch) | |
tree | e58df0ea79275d70b7907d3018357bb9adbe7770 | |
parent | 2994586faac6a804b2d2b910133763ceb16134a0 (diff) |
loplugin:badstatics
ScAddInListener has a member
ScAddInDocs* pDocs; // documents where this is used
where ScAddInDocs is set<ScDocument*>, and ScDocument has a memmber
VclPtr<SfxPrinter> 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 <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | compilerplugins/clang/badstatics.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/check.hxx | 16 |
2 files changed, 18 insertions, 0 deletions
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<std::size_t N> inline ContextCheck Var(char const (& id)[N]) + const; + ContextCheck MemberFunction() const; private: @@ -198,6 +201,19 @@ template<std::size_t N> ContextCheck DeclCheck::Function(char const (& id)[N]) return ContextCheck(); } +template<std::size_t N> ContextCheck DeclCheck::Var(char const (& id)[N]) + const +{ + auto f = llvm::dyn_cast_or_null<clang::VarDecl>(decl_); + if (f != nullptr) { + auto const i = f->getIdentifier(); + if (i != nullptr && i->isStr(id)) { + return ContextCheck(f->getDeclContext()); + } + } + return ContextCheck(); +} + template<std::size_t N> ContextCheck ContextCheck::Namespace( char const (& id)[N]) const { |