diff options
author | Daniel Jasper <djasper@google.com> | 2012-07-30 05:03:25 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-07-30 05:03:25 +0000 |
commit | 9bd2809085c2a84c980c40988896ee05065f14e4 (patch) | |
tree | f6c58ddaf6929d56ed1951fcca42f2bc69dd1b88 | |
parent | dfa210b1e1e403855557f68fe471212787b8540e (diff) |
Fix for ASTMatchFinder to visit a functions parameter declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160947 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ASTMatchers/ASTMatchFinder.cpp | 3 | ||||
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index a58d4f0fb4..085049debd 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -467,8 +467,9 @@ bool MatchASTVisitor::TraverseType(QualType TypeNode) { } bool MatchASTVisitor::TraverseTypeLoc(TypeLoc TypeLoc) { + match(TypeLoc.getType()); return RecursiveASTVisitor<MatchASTVisitor>:: - TraverseType(TypeLoc.getType()); + TraverseTypeLoc(TypeLoc); } class MatchASTConsumer : public ASTConsumer { diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 91095eb3ff..8768baf186 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -859,6 +859,12 @@ TEST(Matcher, VariableUsage) { "}", Reference)); } +TEST(Matcher, FindsVarDeclInFuncitonParameter) { + EXPECT_TRUE(matches( + "void f(int i) {}", + variable(hasName("i")))); +} + TEST(Matcher, CalledVariable) { StatementMatcher CallOnVariableY = expression( memberCall(on(declarationReference(to(variable(hasName("y"))))))); |