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

Manuel Klimek klimek at google.com
Mon May 6 02:05:59 PDT 2013



================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3356
@@ +3355,3 @@
+/// statement.
+AST_MATCHER_P(SwitchStmt, eachCase, internal::Matcher<SwitchCase>,
+              InnerMatcher) {
----------------
I'd prefer if we somehow find a different solution than having traversal implemented in more matchers.

I think that with the upcoming backwards references, this can be expressed as:
switchStmt(
  stmt().bind("x"),
  forEachDescendant(
    caseStmt(hasAcenstor(switchStmt(equalsBoundNode("x"))))
  )
)
And while I'm not completely happy with the matcher, I think that'll buy us time to come up with a better design for doing matchers like this (basically getting early exit for forEachDescendant style matchers).


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



More information about the cfe-commits mailing list