From: Daniel Jasper Date: Mon, 30 Jul 2012 05:03:25 +0000 (+0000) Subject: Fix for ASTMatchFinder to visit a functions parameter declarations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bd2809085c2a84c980c40988896ee05065f14e4;p=clang 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 --- 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:: - 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")))))));