[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann
sbergman at redhat.com
Wed Jun 29 09:32:10 UTC 2016
compilerplugins/clang/check.cxx | 5 +++++
compilerplugins/clang/check.hxx | 2 ++
compilerplugins/clang/passstuffbyref.cxx | 10 ++++------
3 files changed, 11 insertions(+), 6 deletions(-)
New commits:
commit 5d88bf766c8951b15010c8080c3cb56d52321fb2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jun 29 11:31:13 2016 +0200
Further clean-up
Change-Id: Ice5fcb8f598b079afde3346f569d9619f1383506
diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx
index c66a902..af95326 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 8381aec..d69acc2 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 168550b..1d9339a 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());
More information about the Libreoffice-commits
mailing list