summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unusedfields.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-25 13:29:30 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-05-25 15:46:01 +0200
commitcc146f7a12ee0c0e829d2827117558f9cba11858 (patch)
tree816d6e1704eca9d927ad31fa9b84d0c2137fe468 /compilerplugins/clang/unusedfields.cxx
parent953d2704025ef31198f5546ad95cc54401b592a9 (diff)
Code duplication
Change-Id: I1af2948e0332044ef88bc7dbd837e8c7afe7af19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94785 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/unusedfields.cxx')
-rw-r--r--compilerplugins/clang/unusedfields.cxx25
1 files changed, 1 insertions, 24 deletions
diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx
index e4f3f5ba7983..6bbb35930696 100644
--- a/compilerplugins/clang/unusedfields.cxx
+++ b/compilerplugins/clang/unusedfields.cxx
@@ -1144,29 +1144,6 @@ bool UnusedFields::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
return true;
}
-static const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt)
-{
- auto const parents = context.getParents(*stmt);
- auto it = parents.begin();
-
- if (it == parents.end())
- return nullptr;
-
- const Decl *decl = it->get<Decl>();
- if (decl)
- {
- if (isa<VarDecl>(decl))
- return dyn_cast<FunctionDecl>(decl->getDeclContext());
- return decl;
- }
-
- stmt = it->get<Stmt>();
- if (stmt)
- return getFunctionDeclContext(context, stmt);
-
- return nullptr;
-}
-
void UnusedFields::checkTouchedFromOutside(const FieldDecl* fieldDecl, const Expr* memberExpr) {
const FunctionDecl* memberExprParentFunction = getParentFunctionDecl(memberExpr);
const CXXMethodDecl* methodDecl = dyn_cast_or_null<CXXMethodDecl>(memberExprParentFunction);
@@ -1180,7 +1157,7 @@ void UnusedFields::checkTouchedFromOutside(const FieldDecl* fieldDecl, const Exp
if (memberExprParentFunction)
memberExprParentFunction->dump();
memberExpr->dump();
- const Decl *decl = getFunctionDeclContext(compiler.getASTContext(), memberExpr);
+ const Decl *decl = loplugin::getFunctionDeclContext(compiler.getASTContext(), memberExpr);
if (decl)
decl->dump();
std::cout << "site1" << std::endl;