Browse Source

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

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

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56751

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351597 91177308-0d34-0410-b5e6-96231b3b80d8
Stephen Kelly 6 years ago
parent
commit
a5347e0eea
3 changed files with 11 additions and 14 deletions
  1. 6 8
      lib/AST/ASTDumper.cpp
  2. 2 0
      lib/AST/TextNodeDumper.cpp
  3. 3 6
      test/AST/ast-dump-decl.m

+ 6 - 8
lib/AST/ASTDumper.cpp

@@ -164,8 +164,6 @@ namespace  {
       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 @@ void ASTDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
   NodeDumper.dumpName(D);
   NodeDumper.dumpType(D->getReturnType());
 
+  if (D->isVariadic())
+    OS << " variadic";
+
   if (D->isThisDeclarationADefinition()) {
     dumpDeclContext(D);
   } else {
@@ -1243,9 +1244,6 @@ void ASTDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
       dumpDecl(Parameter);
   }
 
-  if (D->isVariadic())
-    dumpChild([=] { OS << "..."; });
-
   if (D->hasBody())
     dumpStmt(D->getBody());
 }
@@ -1378,12 +1376,12 @@ void ASTDumper::Visit(const BlockDecl::Capture &C) {
 }
 
 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"; });
 

+ 2 - 0
lib/AST/TextNodeDumper.cpp

@@ -1096,6 +1096,8 @@ void TextNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) {
     OS << " volatile";
   if (T->isRestrict())
     OS << " restrict";
+  if (T->getExtProtoInfo().Variadic)
+    OS << " variadic";
   switch (EPI.RefQualifier) {
   case RQ_None:
     break;

+ 3 - 6
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 @@ void TestBlockDecl(int x) {
   ^(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