From 7148d5544fd271c0d3d020953643c5e715c0a3ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 15 Jan 2019 20:17:33 +0000 Subject: [PATCH] Implement CXXCtorInitializer dump in terms of Visitor Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56707 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351235 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/TextNodeDumper.h | 2 ++ lib/AST/ASTDumper.cpp | 12 +----------- lib/AST/TextNodeDumper.cpp | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/clang/AST/TextNodeDumper.h b/include/clang/AST/TextNodeDumper.h index 72f2ef6661..a5cc47f00b 100644 --- a/include/clang/AST/TextNodeDumper.h +++ b/include/clang/AST/TextNodeDumper.h @@ -167,6 +167,8 @@ public: void Visit(const Decl *D); + void Visit(const CXXCtorInitializer *Init); + void dumpPointer(const void *Ptr); void dumpLocation(SourceLocation Loc); void dumpSourceRange(SourceRange R); diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index d3ce32c34a..49774aabdf 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -441,17 +441,7 @@ void ASTDumper::dumpAttr(const Attr *A) { void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) { dumpChild([=] { - OS << "CXXCtorInitializer"; - if (Init->isAnyMemberInitializer()) { - OS << ' '; - NodeDumper.dumpBareDeclRef(Init->getAnyMember()); - } else if (Init->isBaseInitializer()) { - NodeDumper.dumpType(QualType(Init->getBaseClass(), 0)); - } else if (Init->isDelegatingInitializer()) { - NodeDumper.dumpType(Init->getTypeSourceInfo()->getType()); - } else { - llvm_unreachable("Unknown initializer type"); - } + NodeDumper.Visit(Init); dumpStmt(Init->getInit()); }); } diff --git a/lib/AST/TextNodeDumper.cpp b/lib/AST/TextNodeDumper.cpp index 189a518075..97fcaba2c9 100644 --- a/lib/AST/TextNodeDumper.cpp +++ b/lib/AST/TextNodeDumper.cpp @@ -258,6 +258,20 @@ void TextNodeDumper::Visit(const Decl *D) { OS << " constexpr"; } +void TextNodeDumper::Visit(const CXXCtorInitializer *Init) { + OS << "CXXCtorInitializer"; + if (Init->isAnyMemberInitializer()) { + OS << ' '; + dumpBareDeclRef(Init->getAnyMember()); + } else if (Init->isBaseInitializer()) { + dumpType(QualType(Init->getBaseClass(), 0)); + } else if (Init->isDelegatingInitializer()) { + dumpType(Init->getTypeSourceInfo()->getType()); + } else { + llvm_unreachable("Unknown initializer type"); + } +} + void TextNodeDumper::dumpPointer(const void *Ptr) { ColorScope Color(OS, ShowColors, AddressColor); OS << ' ' << Ptr; -- 2.40.0