Skip to content

Commit

Permalink
Remove an unsafe member variable that wasn't needed; NFC.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AaronBallman committed Sep 19, 2019
1 parent f15b946 commit 666dcfb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 0 additions & 2 deletions include/clang/AST/TextNodeDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ class TextNodeDumper

const comments::CommandTraits *Traits;

const ASTContext *Context;

const char *getCommandName(unsigned CommandID);

public:
Expand Down
3 changes: 1 addition & 2 deletions lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ void TextNodeDumper::Visit(const Decl *D) {
return;
}

Context = &D->getASTContext();
{
ColorScope Color(OS, ShowColors, DeclKindNameColor);
OS << D->getDeclKindName() << "Decl";
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 666dcfb

Please sign in to comment.