[PATCH] D13249: Divide TraverseInitListExpr to a different function for each form.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 06:58:41 PDT 2015


klimek added inline comments.

================
Comment at: include/clang/AST/RecursiveASTVisitor.h:2066-2089
@@ -2058,26 +2065,26 @@
 
-// InitListExpr is a tricky one, because we want to do all our work on
-// the syntactic form of the listexpr, but this method takes the
-// semantic form by default.  We can't use the macro helper because it
-// calls WalkUp*() on the semantic form, before our code can convert
-// to the syntactic form.
 template <typename Derived>
-bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) {
+bool RecursiveASTVisitor<Derived>::TraverseSyntacticInitListExpr(InitListExpr *S) {
   InitListExpr *Syn = S->isSemanticForm() ? S->getSyntacticForm() : S;
   if (Syn) {
     TRY_TO(WalkUpFromInitListExpr(Syn));
     // All we need are the default actions.  FIXME: use a helper function.
     for (Stmt *SubStmt : Syn->children()) {
       TRY_TO(TraverseStmt(SubStmt));
     }
   }
+  return true;
+}
+
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::TraverseSemanticInitListExpr(InitListExpr *S) {
   InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm();
   if (Sem) {
     TRY_TO(WalkUpFromInitListExpr(Sem));
     for (Stmt *SubStmt : Sem->children()) {
       TRY_TO(TraverseStmt(SubStmt));
     }
   }
   return true;
 }
 
----------------
Ok, I'd now pull out the first line of these functions into the TraverseInitListExpr, and then we only need one function here, right?

================
Comment at: include/clang/AST/RecursiveASTVisitor.h:2091-2095
@@ -2083,1 +2090,7 @@
 
+// InitListExpr is a tricky one, because we want to do all our work on
+// the syntactic form of the listexpr, but this method takes the
+// semantic form by default.  We can't use the macro helper because it
+// calls WalkUp*() on the semantic form, before our code can convert
+// to the syntactic form.
+//
----------------
I think we can remove this - I'm not sure it adds value.


http://reviews.llvm.org/D13249





More information about the cfe-commits mailing list