summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2019-05-16 17:57:38 +0000
committerStephen Kelly <steveire@gmail.com>2019-05-16 17:57:38 +0000
commitd147cea3b94f98e8e1318cac3a4894c2959e230c (patch)
treea89f3104bb0e87f49a968b1fd5828a978776731a /clang/lib/ASTMatchers
parentf8f788b2054e2327524454e603db931b3ac6d08e (diff)
downloadbcm5719-llvm-d147cea3b94f98e8e1318cac3a4894c2959e230c.tar.gz
bcm5719-llvm-d147cea3b94f98e8e1318cac3a4894c2959e230c.zip
Move TraversalKind enum to ast_type_traits
Summary: Make it usable outside of ASTMatchFinder. This will make it possible to use this enum to control whether certain implicit nodes are skipped while AST dumping for example. Reviewers: klimek, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61836 llvm-svn: 360920
Diffstat (limited to 'clang/lib/ASTMatchers')
-rw-r--r--clang/lib/ASTMatchers/ASTMatchFinder.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 45e08f80275..f407e0875ac 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -83,20 +83,12 @@ public:
// descendants of a traversed node. max_depth is the maximum depth
// to traverse: use 1 for matching the children and INT_MAX for
// matching the descendants.
- MatchChildASTVisitor(const DynTypedMatcher *Matcher,
- ASTMatchFinder *Finder,
- BoundNodesTreeBuilder *Builder,
- int MaxDepth,
- ASTMatchFinder::TraversalKind Traversal,
+ MatchChildASTVisitor(const DynTypedMatcher *Matcher, ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder, int MaxDepth,
+ ast_type_traits::TraversalKind Traversal,
ASTMatchFinder::BindKind Bind)
- : Matcher(Matcher),
- Finder(Finder),
- Builder(Builder),
- CurrentDepth(0),
- MaxDepth(MaxDepth),
- Traversal(Traversal),
- Bind(Bind),
- Matches(false) {}
+ : Matcher(Matcher), Finder(Finder), Builder(Builder), CurrentDepth(0),
+ MaxDepth(MaxDepth), Traversal(Traversal), Bind(Bind), Matches(false) {}
// Returns true if a match is found in the subtree rooted at the
// given AST node. This is done via a set of mutually recursive
@@ -151,7 +143,8 @@ public:
ScopedIncrement ScopedDepth(&CurrentDepth);
Stmt *StmtToTraverse = StmtNode;
- if (Traversal == ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses) {
+ if (Traversal ==
+ ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
if (Expr *ExprNode = dyn_cast_or_null<Expr>(StmtNode))
StmtToTraverse = ExprNode->IgnoreParenImpCasts();
}
@@ -299,7 +292,7 @@ private:
BoundNodesTreeBuilder ResultBindings;
int CurrentDepth;
const int MaxDepth;
- const ASTMatchFinder::TraversalKind Traversal;
+ const ast_type_traits::TraversalKind Traversal;
const ASTMatchFinder::BindKind Bind;
bool Matches;
};
@@ -393,7 +386,8 @@ public:
bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder, int MaxDepth,
- TraversalKind Traversal, BindKind Bind) {
+ ast_type_traits::TraversalKind Traversal,
+ BindKind Bind) {
// For AST-nodes that don't have an identity, we can't memoize.
if (!Node.getMemoizationData() || !Builder->isComparable())
return matchesRecursively(Node, Matcher, Builder, MaxDepth, Traversal,
@@ -427,7 +421,8 @@ public:
bool matchesRecursively(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder, int MaxDepth,
- TraversalKind Traversal, BindKind Bind) {
+ ast_type_traits::TraversalKind Traversal,
+ BindKind Bind) {
MatchChildASTVisitor Visitor(
&Matcher, this, Builder, MaxDepth, Traversal, Bind);
return Visitor.findMatch(Node);
@@ -441,7 +436,7 @@ public:
bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
- TraversalKind Traversal,
+ ast_type_traits::TraversalKind Traversal,
BindKind Bind) override {
if (ResultCache.size() > MaxMemoizationEntries)
ResultCache.clear();
@@ -456,7 +451,8 @@ public:
if (ResultCache.size() > MaxMemoizationEntries)
ResultCache.clear();
return memoizedMatchesRecursively(Node, Matcher, Builder, INT_MAX,
- TK_AsIs, Bind);
+ ast_type_traits::TraversalKind::TK_AsIs,
+ Bind);
}
// Implements ASTMatchFinder::matchesAncestorOf.
bool matchesAncestorOf(const ast_type_traits::DynTypedNode &Node,
OpenPOWER on IntegriCloud