r372323 - Remove an unsafe member variable that wasn't needed; NFC.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 06:51:50 PDT 2019


Author: aaronballman
Date: Thu Sep 19 06:51:50 2019
New Revision: 372323

URL: http://llvm.org/viewvc/llvm-project?rev=372323&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/TextNodeDumper.h
    cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=372323&r1=372322&r2=372323&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Thu Sep 19 06:51:50 2019
@@ -146,8 +146,6 @@ class TextNodeDumper
 
   const comments::CommandTraits *Traits;
 
-  const ASTContext *Context;
-
   const char *getCommandName(unsigned CommandID);
 
 public:

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=372323&r1=372322&r2=372323&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Thu Sep 19 06:51:50 2019
@@ -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(c
   if (Node->getResultAPValueKind() != APValue::None) {
     ColorScope Color(OS, ShowColors, ValueColor);
     OS << " ";
-    Node->getAPValueResult().printPretty(OS, *Context, Node->getType());
+    Node->getAPValueResult().dump(OS);
   }
 }
 




More information about the cfe-commits mailing list