[PATCH] Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.

Manuel Klimek klimek at google.com
Fri May 10 01:08:21 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.
+///
----------------
Nit: we don't use double space in comment.

================
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:; } }",
----------------
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 :)


http://llvm-reviews.chandlerc.com/D744



More information about the cfe-commits mailing list