aboutsummaryrefslogtreecommitdiff
path: root/lib/ASTMatchers
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-10-22 16:26:51 +0000
committerDaniel Jasper <djasper@google.com>2012-10-22 16:26:51 +0000
commitc99a3ad8c2bf29da45a0c64b88d58bfbd2f78ef2 (patch)
tree46666ad15f3d32214b14a00619023b24cb63ad6e /lib/ASTMatchers
parent03e6fda61f48a6f11fb3c9459d5ac3d5b1db2809 (diff)
Implement hasParent()-matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ASTMatchers')
-rw-r--r--lib/ASTMatchers/ASTMatchFinder.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp
index ebbadc424d..c0d97df075 100644
--- a/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -352,7 +352,7 @@ public:
const Matcher<NamedDecl> &Base,
BoundNodesTreeBuilder *Builder);
- // Implements ASTMatchFinder::MatchesChildOf.
+ // Implements ASTMatchFinder::matchesChildOf.
virtual bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
@@ -361,7 +361,7 @@ public:
return matchesRecursively(Node, Matcher, Builder, 1, Traversal,
Bind);
}
- // Implements ASTMatchFinder::MatchesDescendantOf.
+ // Implements ASTMatchFinder::matchesDescendantOf.
virtual bool matchesDescendantOf(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
@@ -372,7 +372,8 @@ public:
// Implements ASTMatchFinder::matchesAncestorOf.
virtual bool matchesAncestorOf(const ast_type_traits::DynTypedNode &Node,
const DynTypedMatcher &Matcher,
- BoundNodesTreeBuilder *Builder) {
+ BoundNodesTreeBuilder *Builder,
+ AncestorMatchMode MatchMode) {
if (!Parents) {
// We always need to run over the whole translation unit, as
// \c hasAncestor can escape any subtree.
@@ -395,6 +396,8 @@ public:
Ancestor = I->second;
if (Matcher.matches(Ancestor, this, Builder))
return true;
+ if (MatchMode == ASTMatchFinder::AMM_ParentOnly)
+ return false;
}
return false;
}