From: Stephen Kelly Date: Tue, 15 Jan 2019 22:50:37 +0000 (+0000) Subject: Re-order overrides in FunctionDecl dump X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=afd1663033f23195e3bc14359925d1d86a8b89c5;p=clang Re-order overrides in FunctionDecl dump Output all content which is local to the FunctionDecl before traversing to child AST nodes. This is necessary so that all of the part which is local to the FunctionDecl can be split into a different method. Reviewers: aaron.ballman Differential Revision: https://reviews.llvm.org/D55083 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351269 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index bd7571b536..f982b1fbe3 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -612,20 +612,6 @@ void ASTDumper::VisitFunctionDecl(const FunctionDecl *D) { } } - if (const FunctionTemplateSpecializationInfo *FTSI = - D->getTemplateSpecializationInfo()) - dumpTemplateArgumentList(*FTSI->TemplateArguments); - - if (!D->param_begin() && D->getNumParams()) - dumpChild([=] { OS << "<getNumParams() << ">>"; }); - else - for (const ParmVarDecl *Parameter : D->parameters()) - dumpDecl(Parameter); - - if (const CXXConstructorDecl *C = dyn_cast(D)) - for (const auto *I : C->inits()) - dumpCXXCtorInitializer(I); - if (const CXXMethodDecl *MD = dyn_cast(D)) { if (MD->size_overridden_methods() != 0) { auto dumpOverride = [=](const CXXMethodDecl *D) { @@ -649,6 +635,22 @@ void ASTDumper::VisitFunctionDecl(const FunctionDecl *D) { } } + if (const FunctionTemplateSpecializationInfo *FTSI = + D->getTemplateSpecializationInfo()) + dumpTemplateArgumentList(*FTSI->TemplateArguments); + + if (!D->param_begin() && D->getNumParams()) + dumpChild([=] { OS << "<getNumParams() << ">>"; }); + else + for (const ParmVarDecl *Parameter : D->parameters()) + dumpDecl(Parameter); + + if (const CXXConstructorDecl *C = dyn_cast(D)) + for (CXXConstructorDecl::init_const_iterator I = C->init_begin(), + E = C->init_end(); + I != E; ++I) + dumpCXXCtorInitializer(*I); + if (D->doesThisDeclarationHaveABody()) dumpStmt(D->getBody()); } diff --git a/test/AST/ast-dump-funcs.cpp b/test/AST/ast-dump-funcs.cpp index cbd430d01f..62ae9648dd 100644 --- a/test/AST/ast-dump-funcs.cpp +++ b/test/AST/ast-dump-funcs.cpp @@ -56,10 +56,10 @@ struct S { struct T : S { // T is not referenced, but S is void f(float, int = 100) override; // CHECK: CXXMethodDecl 0x{{[^ ]*}} col:8 f 'void (float, int)' + // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ] // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} col:15 'float' // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} col:21 'int' cinit // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 100 - // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ] // CHECK-NEXT: OverrideAttr // CHECK: CXXConstructorDecl 0x{{[^ ]*}} col:8 implicit T 'void (const T &)' inline default_delete noexcept-unevaluated