[PATCH] D56751: [ASTDump] Mark variadic declarations with a tag instead of child node

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 15 15:36:29 PST 2019


steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

This makes it easier to separate traversal of the AST from output
generation.


Repository:
  rC Clang

https://reviews.llvm.org/D56751

Files:
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp
  test/AST/ast-dump-decl.m


Index: test/AST/ast-dump-decl.m
===================================================================
--- test/AST/ast-dump-decl.m
+++ test/AST/ast-dump-decl.m
@@ -28,20 +28,18 @@
 @interface testObjCMethodDecl : A {
 }
 - (int) TestObjCMethodDecl: (int)i, ...;
-// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int'
+// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
-// CHECK-NEXT:   ...
 @end
 
 @implementation testObjCMethodDecl
 - (int) TestObjCMethodDecl: (int)i, ... {
   return 0;
 }
-// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int'
+// CHECK:      ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
 // CHECK-NEXT:   ImplicitParamDecl{{.*}} self
 // CHECK-NEXT:   ImplicitParamDecl{{.*}} _cmd
 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
-// CHECK-NEXT:   ...
 // CHECK-NEXT:   CompoundStmt
 @end
 
@@ -137,9 +135,8 @@
   ^(int y, ...){ x; };
 }
 // CHECK:      FunctionDecl{{.*}}TestBlockDecl
-// CHECK:      BlockDecl
+// CHECK:      BlockDecl {{.+}} <col:3, col:21> col:3 variadic
 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
-// CHECK-NEXT:   ...
 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
 // CHECK-NEXT:   CompoundStmt
 
Index: lib/AST/TextNodeDumper.cpp
===================================================================
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -1096,6 +1096,8 @@
     OS << " volatile";
   if (T->isRestrict())
     OS << " restrict";
+  if (T->getExtProtoInfo().Variadic)
+    OS << " variadic";
   switch (EPI.RefQualifier) {
   case RQ_None:
     break;
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -164,8 +164,6 @@
       VisitFunctionType(T);
       for (QualType PT : T->getParamTypes())
         dumpTypeAsChild(PT);
-      if (T->getExtProtoInfo().Variadic)
-        dumpChild([=] { OS << "..."; });
     }
     void VisitTypeOfExprType(const TypeOfExprType *T) {
       dumpStmt(T->getUnderlyingExpr());
@@ -1236,6 +1234,9 @@
   NodeDumper.dumpName(D);
   NodeDumper.dumpType(D->getReturnType());
 
+  if (D->isVariadic())
+    OS << " variadic";
+
   if (D->isThisDeclarationADefinition()) {
     dumpDeclContext(D);
   } else {
@@ -1243,9 +1244,6 @@
       dumpDecl(Parameter);
   }
 
-  if (D->isVariadic())
-    dumpChild([=] { OS << "..."; });
-
   if (D->hasBody())
     dumpStmt(D->getBody());
 }
@@ -1378,12 +1376,12 @@
 }
 
 void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
+  if (D->isVariadic())
+    OS << " variadic";
+
   for (auto I : D->parameters())
     dumpDecl(I);
 
-  if (D->isVariadic())
-    dumpChild([=]{ OS << "..."; });
-
   if (D->capturesCXXThis())
     dumpChild([=]{ OS << "capture this"; });
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56751.181904.patch
Type: text/x-patch
Size: 2810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190115/4d3d4dab/attachment.bin>


More information about the cfe-commits mailing list