diff options
author | Daniel Jasper <djasper@google.com> | 2012-09-13 13:11:25 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-09-13 13:11:25 +0000 |
commit | a7564433191601cb8851196b8dde39392c9c05ee (patch) | |
tree | cf310bc120ba0f78e26053fa973b74b72ea9edc7 /lib/ASTMatchers | |
parent | 1824d54df85a462ada812dadda18130f951d40f3 (diff) |
Create initial support for matching and binding NestedNameSpecifier(Loc)s.
Review: http://llvm-reviews.chandlerc.com/D39
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ASTMatchers')
-rw-r--r-- | lib/ASTMatchers/ASTMatchFinder.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index afab1df4a6..cba2e50337 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -313,6 +313,8 @@ public: bool TraverseStmt(Stmt *StmtNode); bool TraverseType(QualType TypeNode); bool TraverseTypeLoc(TypeLoc TypeNode); + bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); + bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS); // Matches children or descendants of 'Node' with 'BaseMatcher'. bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode &Node, @@ -556,6 +558,21 @@ bool MatchASTVisitor::TraverseTypeLoc(TypeLoc TypeLoc) { TraverseTypeLoc(TypeLoc); } +bool MatchASTVisitor::TraverseNestedNameSpecifier(NestedNameSpecifier *NNS) { + match(*NNS); + return RecursiveASTVisitor<MatchASTVisitor>::TraverseNestedNameSpecifier(NNS); +} + +bool MatchASTVisitor::TraverseNestedNameSpecifierLoc( + NestedNameSpecifierLoc NNS) { + match(NNS); + // We only match the nested name specifier here (as opposed to traversing it) + // because the traversal is already done in the parallel "Loc"-hierarchy. + match(*NNS.getNestedNameSpecifier()); + return + RecursiveASTVisitor<MatchASTVisitor>::TraverseNestedNameSpecifierLoc(NNS); +} + class MatchASTConsumer : public ASTConsumer { public: MatchASTConsumer( @@ -619,6 +636,18 @@ void MatchFinder::addMatcher(const StatementMatcher &NodeMatch, new internal::Matcher<Stmt>(NodeMatch), Action)); } +void MatchFinder::addMatcher(const NestedNameSpecifierMatcher &NodeMatch, + MatchCallback *Action) { + MatcherCallbackPairs.push_back(std::make_pair( + new NestedNameSpecifierMatcher(NodeMatch), Action)); +} + +void MatchFinder::addMatcher(const NestedNameSpecifierLocMatcher &NodeMatch, + MatchCallback *Action) { + MatcherCallbackPairs.push_back(std::make_pair( + new NestedNameSpecifierLocMatcher(NodeMatch), Action)); +} + ASTConsumer *MatchFinder::newASTConsumer() { return new internal::MatchASTConsumer(&MatcherCallbackPairs, ParsingDone); } |