Author: Stephen Kelly Date: 2019-12-18T22:33:23Z New Revision: a9f597b62ebdb670392fec2d5a5154e43b6398aa
URL: https://github.com/llvm/llvm-project/commit/a9f597b62ebdb670392fec2d5a5154e43b6398aa DIFF: https://github.com/llvm/llvm-project/commit/a9f597b62ebdb670392fec2d5a5154e43b6398aa.diff LOG: Output names in the AST in tests Added: Modified: clang/unittests/AST/ASTTraverserTest.cpp Removed: ################################################################################ diff --git a/clang/unittests/AST/ASTTraverserTest.cpp b/clang/unittests/AST/ASTTraverserTest.cpp index 69812cb8d21c..99d4589c48a3 100644 --- a/clang/unittests/AST/ASTTraverserTest.cpp +++ b/clang/unittests/AST/ASTTraverserTest.cpp @@ -27,9 +27,19 @@ class NodeTreePrinter : public TextTreeStructure { NodeTreePrinter(llvm::raw_ostream &OS) : TextTreeStructure(OS, /* showColors */ false), OS(OS) {} - void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; } + void Visit(const Decl *D) { + OS << D->getDeclKindName() << "Decl"; + if (auto *ND = dyn_cast<NamedDecl>(D)) { + OS << " '" << ND->getDeclName() << "'"; + } + } - void Visit(const Stmt *S) { OS << S->getStmtClassName(); } + void Visit(const Stmt *S) { + OS << S->getStmtClassName(); + if (auto *E = dyn_cast<DeclRefExpr>(S)) { + OS << " '" << E->getDecl()->getDeclName() << "'"; + } + } void Visit(QualType QT) { OS << "QualType " << QT.split().Quals.getAsString(); @@ -147,7 +157,7 @@ void parmvardecl_attr(struct A __attribute__((address_space(19)))*); verifyWithDynNode(Func, R"cpp( -CXXMethodDecl +CXXMethodDecl 'func' |-CompoundStmt | `-ReturnStmt | `-IntegerLiteral _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits