diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-06-29 11:31:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-06-29 11:31:13 +0200 |
commit | 5d88bf766c8951b15010c8080c3cb56d52321fb2 (patch) | |
tree | aba541d3b06bee03ad2cfc18941aebc1c3342183 /compilerplugins/clang | |
parent | 541fcc978d69e6ba10e4005fd6e38658100bc112 (diff) |
Further clean-up
Change-Id: Ice5fcb8f598b079afde3346f569d9619f1383506
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/check.cxx | 5 | ||||
-rw-r--r-- | compilerplugins/clang/check.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/passstuffbyref.cxx | 10 |
3 files changed, 11 insertions, 6 deletions
diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx index c66a9026422e..af9532620920 100644 --- a/compilerplugins/clang/check.cxx +++ b/compilerplugins/clang/check.cxx @@ -82,6 +82,11 @@ ContextCheck DeclCheck::Operator(clang::OverloadedOperatorKind op) const { ? f->getDeclContext() : nullptr); } +ContextCheck DeclCheck::MemberFunction() const { + auto m = llvm::dyn_cast_or_null<clang::CXXMethodDecl>(decl_); + return ContextCheck(m == nullptr ? nullptr : m->getParent()); +} + TerminalCheck ContextCheck::GlobalNamespace() const { return TerminalCheck( context_ != nullptr diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx index 8381aec084b5..d69acc264243 100644 --- a/compilerplugins/clang/check.hxx +++ b/compilerplugins/clang/check.hxx @@ -73,6 +73,8 @@ public: ContextCheck Operator(clang::OverloadedOperatorKind op) const; + ContextCheck MemberFunction() const; + private: clang::Decl const * const decl_; }; diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index 168550bcdcbb..1d9339a31c48 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -73,10 +73,6 @@ private: std::vector<FDecl> functionDecls_; }; -bool startswith(const std::string& rStr, const char* pSubStr) { - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - bool PassStuffByRef::TraverseFunctionDecl(FunctionDecl * decl) { return traverseAnyFunctionDecl( decl, &RecursiveASTVisitor::TraverseFunctionDecl); @@ -207,8 +203,10 @@ void PassStuffByRef::checkParams(const FunctionDecl * functionDecl) { return; } // these functions are passed as parameters to another function - std::string aFunctionName = functionDecl->getQualifiedNameAsString(); - if (startswith(aFunctionName, "slideshow::internal::ShapeAttributeLayer")) { + if (loplugin::DeclCheck(functionDecl).MemberFunction() + .Class("ShapeAttributeLayer").Namespace("internal") + .Namespace("slideshow").GlobalNamespace()) + { return; } assert(!functionDecls_.empty()); |