[PATCH] D28260: Add an argumentsAre matcher
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 10 08:20:31 PST 2017
aaron.ballman requested changes to this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision now requires changes to proceed.
You should also regenerate the HTML matcher documentation as part of this patch.
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3075
+///
+/// Example matches the call to f2, but not f1 or f3.
+/// (matcher = callExpr(argumentsAre(declRefExpr(), declRefExpr())))
----------------
This is a neat matcher, but I'm not certain it will work with the dynamic matchers, which is an unfortunate divergence for clang-query.
Another concern is that this is leaking implementation details into ASTMatchers.h rather than keeping them in ASTMatchersInternal.h.
================
Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:383
+ EXPECT_TRUE(matches("void f(int x, int y) { f(x, y); }", Call));
+ EXPECT_TRUE(notMatches("void f(int x, int y, int z) { f(x, y, z); }", Call));
+}
----------------
How does this matcher work in the presence of default arguments? e.g.,
```
void f(int a, int b = 12);
f(1);
```
Will `callExpr(argumentsAre(integerLiteral()))` match?
A similar question applies for variadic functions and functions without a prototype (from C).
I suspect it all works fine, but some test cases would be nice.
https://reviews.llvm.org/D28260
More information about the cfe-commits
mailing list