[PATCH] D17446: ASTMatchers: add new statement/decl matchers

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 19 06:58:02 PST 2016


aaron.ballman added a comment.

Given the wide disparity of functionality, I'm wondering if there are concrete purposes for these new matchers?


================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:1599
@@ -1543,1 +1598,3 @@
 
+/// \brief Matches atomic builtins.
+const internal::VariadicDynCastAllOfMatcher<
----------------
This is a bit *too* brief. It would be good to give some example code.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:1608
@@ +1607,3 @@
+/// \code
+///   int C = ({ int X = 4; X: });
+/// \endcode
----------------
This code does not look legal to me because of the `X:`. (Same for the Example match: text.)

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:1612
@@ +1611,3 @@
+  Stmt,
+  StmtExpr> stmtExpr;
+
----------------
Did clang-format produce this formatting?

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:1622
@@ +1621,3 @@
+/// \endcode
+AST_MATCHER_P(StmtExpr, hasSubStmt,
+              internal::Matcher<CompoundStmt>, InnerMatcher) {
----------------
I think it makes more sense to extend hasAnySubstatement() to work off stmtExpr() in addition to compoundStmt(). Same may be true for statementCountIs(), if you need it.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3013
@@ +3012,3 @@
+/// zero initialization.
+AST_MATCHER(CXXConstructExpr, requiresZeroInitialization) {
+  return Node.requiresZeroInitialization();
----------------
Missing code example of how to use this and what would match.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3499
@@ +3498,3 @@
+                          AST_POLYMORPHIC_SUPPORTED_TYPES(CastExpr,
+                                                          OpaqueValueExpr),
+                          internal::Matcher<Expr>, InnerMatcher) {
----------------
It would be good to add a new code example as to when this would trigger for an OpaqueValueExpr.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3568
@@ -3417,3 +3567,3 @@
 /// \endcode
-AST_MATCHER_P(ConditionalOperator, hasTrueExpression,
+AST_MATCHER_P(AbstractConditionalOperator, hasTrueExpression,
               internal::Matcher<Expr>, InnerMatcher) {
----------------
Code examples for how this affects binaryConditionalOperator() (here and below) would be welcome.


Repository:
  rL LLVM

http://reviews.llvm.org/D17446





More information about the cfe-commits mailing list