summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2019-01-15 22:50:37 +0000
committerStephen Kelly <steveire@gmail.com>2019-01-15 22:50:37 +0000
commit90edb310c697b2f5008ebd38e377ef8f65bf6a21 (patch)
treea698908ca425040d3d2488f3ded46e679797a2d6
parent6f785b5fd0050ffcb9a6fcbb3b6acd75f00fff90 (diff)
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
-rw-r--r--clang/lib/AST/ASTDumper.cpp30
-rw-r--r--clang/test/AST/ast-dump-funcs.cpp2
2 files changed, 17 insertions, 15 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index bd7571b5366..f982b1fbe36 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/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 << "<<NULL params x " << D->getNumParams() << ">>"; });
- else
- for (const ParmVarDecl *Parameter : D->parameters())
- dumpDecl(Parameter);
-
- if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(D))
- for (const auto *I : C->inits())
- dumpCXXCtorInitializer(I);
-
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(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 << "<<NULL params x " << D->getNumParams() << ">>"; });
+ else
+ for (const ParmVarDecl *Parameter : D->parameters())
+ dumpDecl(Parameter);
+
+ if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(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/clang/test/AST/ast-dump-funcs.cpp b/clang/test/AST/ast-dump-funcs.cpp
index cbd430d01ff..62ae9648dde 100644
--- a/clang/test/AST/ast-dump-funcs.cpp
+++ b/clang/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{{[^ ]*}} <line:[[@LINE-1]]:3, col:28> col:8 f 'void (float, int)'
+ // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
// CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:10> col:15 'float'
// CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:17, col:23> col:21 'int' cinit
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 100
- // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
// CHECK-NEXT: OverrideAttr
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-9]]:8> col:8 implicit T 'void (const T &)' inline default_delete noexcept-unevaluated