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

Angel Garcia via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 08:52:42 PDT 2015


angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

create TraverseSyntacticInitListExpr and TraverseSemanticInitListExpr.

http://reviews.llvm.org/D13249

Files:
  include/clang/AST/RecursiveASTVisitor.h

Index: include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -255,6 +255,13 @@
   /// \returns false if the visitation was terminated early, true otherwise.
   bool TraverseLambdaBody(LambdaExpr *LE);
 
+  /// \brief Recursively visit the syntactic and semantic forms of a
+  /// initialization list.
+  ///
+  /// \returns false if the visitation was terminated early, true otherwise.
+  bool TraverseSyntacticInitListExpr(InitListExpr *S);
+  bool TraverseSemanticInitListExpr(InitListExpr *S);
+
   // ---- Methods on Attrs ----
 
   // \brief Visit an attribute.
@@ -2056,21 +2063,21 @@
   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
 })
 
-// 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));
@@ -2081,6 +2088,18 @@
   return true;
 }
 
+// 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) {
+  TRY_TO(TraverseSyntacticInitListExpr(S));
+  TRY_TO(TraverseSemanticInitListExpr(S));
+  return true;
+}
+
 // GenericSelectionExpr is a special case because the types and expressions
 // are interleaved.  We also need to watch out for null types (default
 // generic associations).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13249.35982.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150929/08f3626f/attachment.bin>


More information about the cfe-commits mailing list