Further clean-up

Change-Id: Ice5fcb8f598b079afde3346f569d9619f1383506
This commit is contained in:
Stephan Bergmann
2016-06-29 11:31:13 +02:00
parent 541fcc978d
commit 5d88bf766c
3 changed files with 11 additions and 6 deletions

View File

@@ -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

View File

@@ -73,6 +73,8 @@ public:
ContextCheck Operator(clang::OverloadedOperatorKind op) const;
ContextCheck MemberFunction() const;
private:
clang::Decl const * const decl_;
};

View File

@@ -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());