[PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 30 06:42:12 PST 2015
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4022
@@ +4021,3 @@
+/// functionProtoType()
+/// matches "int (*f)(int)" and the type of "g".
+AST_TYPE_MATCHER(FunctionProtoType, functionProtoType);
----------------
Will this match g() in C mode?
================
Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4282
@@ +4281,3 @@
+ EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+ EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0))));
+}
----------------
I would like to see tests using matchesC() for void f() (for both functionProtoType() and parameterCountIs()).
================
Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4988
@@ +4987,3 @@
+ EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+ typedefDecl(hasUnderlyingType(asString("int")))));
+}
----------------
Can we have a test for:
```
EXPECT_TRUE(matches("typedef int foo; typedef foo bar;", typedefDecl(hasUnderlyingType(asString("int")), hasName("bar"))));
```
(I assume that this should work?)
http://reviews.llvm.org/D8149
More information about the cfe-commits
mailing list