From 666dcfbdf06778b020d0ba1e51aa2fb03fa66ccc Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 19 Sep 2019 13:51:50 +0000 Subject: Remove an unsafe member variable that wasn't needed; NFC. People use the AST dumping interface while debugging, so it's not safe to assume that a declaration will be dumped before a constant expression is dumped. This means the Context member may not get set properly and problems would happen. Rather than rely on the interface that requires the ASTContext, call the generic dump() interface instead; this allows us to remove the Context member variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372323 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/TextNodeDumper.h | 2 -- lib/AST/TextNodeDumper.cpp | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/clang/AST/TextNodeDumper.h b/include/clang/AST/TextNodeDumper.h index 4c2d071096..0ff5a614a8 100644 --- a/include/clang/AST/TextNodeDumper.h +++ b/include/clang/AST/TextNodeDumper.h @@ -146,8 +146,6 @@ class TextNodeDumper const comments::CommandTraits *Traits; - const ASTContext *Context; - const char *getCommandName(unsigned CommandID); public: diff --git a/lib/AST/TextNodeDumper.cpp b/lib/AST/TextNodeDumper.cpp index df3d149f29..546a62cda2 100644 --- a/lib/AST/TextNodeDumper.cpp +++ b/lib/AST/TextNodeDumper.cpp @@ -223,7 +223,6 @@ void TextNodeDumper::Visit(const Decl *D) { return; } - Context = &D->getASTContext(); { ColorScope Color(OS, ShowColors, DeclKindNameColor); OS << D->getDeclKindName() << "Decl"; @@ -688,7 +687,7 @@ void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) { if (Node->getResultAPValueKind() != APValue::None) { ColorScope Color(OS, ShowColors, ValueColor); OS << " "; - Node->getAPValueResult().printPretty(OS, *Context, Node->getType()); + Node->getAPValueResult().dump(OS); } } -- cgit v1.2.1