[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

llvm-svn: 351597
This commit is contained in:
Stephen Kelly 2019-01-18 21:38:30 +00:00
parent 4599159ac3
commit 149119dc5f
3 changed files with 11 additions and 14 deletions

View File

@ -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"; });

View File

@ -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;

View File

@ -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