]> granicus.if.org Git - clang/commitdiff
Fix for ASTMatchFinder to visit a functions parameter declarations.
authorDaniel Jasper <djasper@google.com>
Mon, 30 Jul 2012 05:03:25 +0000 (05:03 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 30 Jul 2012 05:03:25 +0000 (05:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160947 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ASTMatchers/ASTMatchFinder.cpp
unittests/ASTMatchers/ASTMatchersTest.cpp

index a58d4f0fb4775ac3bfd99bb3987a03f167ae028c..085049debdbed495d20d03b70d35be916cd731cf 100644 (file)
@@ -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 {
index 91095eb3ff1e3f4c1e247b8644da60b510e13993..8768baf18694d96f6526e59dd739cc74b52184c5 100644 (file)
@@ -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")))))));