[cfe-commits] r160947 - in /cfe/trunk: lib/ASTMatchers/ASTMatchFinder.cpp unittests/ASTMatchers/ASTMatchersTest.cpp
Daniel Jasper
djasper at google.com
Sun Jul 29 22:03:25 PDT 2012
Author: djasper
Date: Mon Jul 30 00:03:25 2012
New Revision: 160947
URL: http://llvm.org/viewvc/llvm-project?rev=160947&view=rev
Log:
Fix for ASTMatchFinder to visit a functions parameter declarations.
Modified:
cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=160947&r1=160946&r2=160947&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Mon Jul 30 00:03:25 2012
@@ -467,8 +467,9 @@
}
bool MatchASTVisitor::TraverseTypeLoc(TypeLoc TypeLoc) {
+ match(TypeLoc.getType());
return RecursiveASTVisitor<MatchASTVisitor>::
- TraverseType(TypeLoc.getType());
+ TraverseTypeLoc(TypeLoc);
}
class MatchASTConsumer : public ASTConsumer {
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=160947&r1=160946&r2=160947&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jul 30 00:03:25 2012
@@ -859,6 +859,12 @@
"}", 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")))))));
More information about the cfe-commits
mailing list