From: Stephen Kelly Date: Fri, 18 Jan 2019 21:38:30 +0000 (+0000) Subject: [ASTDump] Mark variadic declarations with a tag instead of child node X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5347e0eeacb98b46f83fdb96dd0c5e3a0fa8bb0;p=clang [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 --- diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index b52ec21943..b99ed3b286 100644 --- a/lib/AST/ASTDumper.cpp +++ b/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"; }); diff --git a/lib/AST/TextNodeDumper.cpp b/lib/AST/TextNodeDumper.cpp index b51a900622..a514f85ef6 100644 --- a/lib/AST/TextNodeDumper.cpp +++ b/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; diff --git a/test/AST/ast-dump-decl.m b/test/AST/ast-dump-decl.m index 7f114dd7cb..6cef98925f 100644 --- a/test/AST/ast-dump-decl.m +++ b/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 variadic // CHECK-NEXT: ParmVarDecl{{.*}} y 'int' -// CHECK-NEXT: ... // CHECK-NEXT: capture ParmVar{{.*}} 'x' 'int' // CHECK-NEXT: CompoundStmt