summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/plugin.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-08-03 14:56:33 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-08-03 23:18:58 +0200
commit5c7e838714f5d071c4882115cef9c843fb603287 (patch)
tree8373a8b33fef444b1840c43adb172c30e8417935 /compilerplugins/clang/plugin.cxx
parente0018be102edd6e376e0622e0a9384176d2f119c (diff)
Revert "Adapt to changed clang::ASTContext::getParents behavior on Clang 11 trunk"
This reverts commit 09aa5a9be8b9b3c88cf25b85e0eda28c5ef19aa4, now that <https://github.com/llvm/llvm-project/commit/ 551092bc3dfb86f1e11a55f3bee0c8ee1be6fdd6> "Revert AST Matchers default to AsIs mode" reverted the Clang commit that prompted this compilerplugins change. Change-Id: I75c8b4cb2894cd67a791db460f2886a783856c73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100026 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/plugin.cxx')
-rw-r--r--compilerplugins/clang/plugin.cxx38
1 files changed, 6 insertions, 32 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index dc7c673a31c3..4e640cfb2c3b 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -184,35 +184,9 @@ bool Plugin::evaluate(const Expr* expr, APSInt& x)
return false;
}
-compat::DynTypedNodeList Plugin::getParents(Decl const & decl)
-{
-#if CLANG_VERSION >= 110000
- if (!parentMapContext_) {
- parentMapContext_.reset(new ParentMapContext(compiler.getASTContext()));
- parentMapContext_->setTraversalKind(TK_AsIs);
- }
- return parentMapContext_->getParents(decl);
-#else
- return compiler.getASTContext().getParents(decl);
-#endif
-}
-
-compat::DynTypedNodeList Plugin::getParents(Stmt const & stmt)
-{
-#if CLANG_VERSION >= 110000
- if (!parentMapContext_) {
- parentMapContext_.reset(new ParentMapContext(compiler.getASTContext()));
- parentMapContext_->setTraversalKind(TK_AsIs);
- }
- return parentMapContext_->getParents(stmt);
-#else
- return compiler.getASTContext().getParents(stmt);
-#endif
-}
-
const Stmt* Plugin::getParentStmt( const Stmt* stmt )
{
- auto parentsRange = getParents(*stmt);
+ auto parentsRange = compiler.getASTContext().getParents(*stmt);
if ( parentsRange.begin() == parentsRange.end())
return nullptr;
return parentsRange.begin()->get<Stmt>();
@@ -220,15 +194,15 @@ const Stmt* Plugin::getParentStmt( const Stmt* stmt )
Stmt* Plugin::getParentStmt( Stmt* stmt )
{
- auto parentsRange = getParents(*stmt);
+ auto parentsRange = compiler.getASTContext().getParents(*stmt);
if ( parentsRange.begin() == parentsRange.end())
return nullptr;
return const_cast<Stmt*>(parentsRange.begin()->get<Stmt>());
}
-const Decl* Plugin::getFunctionDeclContext(const Stmt* stmt)
+const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt)
{
- auto const parents = getParents(*stmt);
+ auto const parents = context.getParents(*stmt);
auto it = parents.begin();
if (it == parents.end())
@@ -244,14 +218,14 @@ const Decl* Plugin::getFunctionDeclContext(const Stmt* stmt)
stmt = it->get<Stmt>();
if (stmt)
- return getFunctionDeclContext(stmt);
+ return getFunctionDeclContext(context, stmt);
return nullptr;
}
const FunctionDecl* Plugin::getParentFunctionDecl( const Stmt* stmt )
{
- const Decl *decl = getFunctionDeclContext(stmt);
+ const Decl *decl = getFunctionDeclContext(compiler.getASTContext(), stmt);
if (decl)
return static_cast<const FunctionDecl*>(decl->getNonClosureContext());