[PATCH] Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.
Peter Collingbourne
peter at pcc.me.uk
Fri May 10 02:34:15 PDT 2013
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3355
@@ +3354,3 @@
+/// \brief Matches each case or default statement belonging to the given switch
+/// statement. This matcher may produce multiple matches.
+///
----------------
Manuel Klimek wrote:
> Nit: we don't use double space in comment.
Changed.
================
Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:2929
@@ +2928,3 @@
+ "void x() { if (1) switch(42) { case 42: switch (42) { default:; } } }",
+ ifStmt(switchStmt(forEachSwitchCase(defaultStmt())))));
+ EXPECT_TRUE(matches("void x() { switch(42) { case 1+1: case 4:; } }",
----------------
Manuel Klimek wrote:
> This can never match anything, as an IfStmt is not a SwitchStmt. I propose to test all test cases by seeing them fail at least once :)
Doh, fixed. (I manually tested my test case by changing defaultStmt to caseStmt temporarily.)
http://llvm-reviews.chandlerc.com/D744
More information about the cfe-commits
mailing list