diff options
author | Stephen Kelly <steveire@gmail.com> | 2019-01-11 19:11:17 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2019-01-11 19:11:17 +0000 |
commit | 0df805db731fa1384c36f18a50b4ec35cbf368f4 (patch) | |
tree | ab903a3323209fd202018a1913f0f0c47f54334d /clang/lib | |
parent | 27ba55914addfd55c9b6e5fa73aae51246424ef2 (diff) | |
download | bcm5719-llvm-0df805db731fa1384c36f18a50b4ec35cbf368f4.tar.gz bcm5719-llvm-0df805db731fa1384c36f18a50b4ec35cbf368f4.zip |
[ASTDump] Add utility for dumping a label with child nodes
Summary:
Use it to add optional label nodes to Stmt dumps. This preserves
behavior of InitExprList dump:
// CHECK-NEXT: `-InitListExpr {{.+}} <col:13, col:15> 'U [3]'
// CHECK-NEXT: |-array_filler: InitListExpr {{.+}} <col:15> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT: `-InitListExpr {{.+}} <col:14> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT: `-IntegerLiteral {{.+}} <col:14> 'int' 1
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D55488
llvm-svn: 350957
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index 698fca0b335..91ca716bade 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -61,6 +61,9 @@ namespace { template<typename Fn> void dumpChild(Fn DoDumpChild) { NodeDumper.AddChild(DoDumpChild); } + template <typename Fn> void dumpChild(StringRef Label, Fn DoDumpChild) { + NodeDumper.AddChild(Label, DoDumpChild); + } public: ASTDumper(raw_ostream &OS, const CommandTraits *Traits, @@ -80,7 +83,7 @@ namespace { void setDeserialize(bool D) { Deserialize = D; } void dumpDecl(const Decl *D); - void dumpStmt(const Stmt *S); + void dumpStmt(const Stmt *S, StringRef Label = {}); // Utilities void dumpType(QualType T) { NodeDumper.dumpType(T); } @@ -1685,8 +1688,8 @@ void ASTDumper::VisitBlockDecl(const BlockDecl *D) { // Stmt dumping methods. //===----------------------------------------------------------------------===// -void ASTDumper::dumpStmt(const Stmt *S) { - dumpChild([=] { +void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) { + dumpChild(Label, [=] { if (!S) { ColorScope Color(OS, ShowColors, NullColor); OS << "<<<NULL>>>"; @@ -1957,10 +1960,7 @@ void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) { NodeDumper.dumpBareDeclRef(Field); } if (auto *Filler = ILE->getArrayFiller()) { - dumpChild([=] { - OS << "array filler"; - dumpStmt(Filler); - }); + dumpStmt(Filler, "array_filler"); } } |