r348200 - [analyzer] Dump stable identifiers for objects under construction.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 3 14:23:21 PST 2018


Author: dergachev
Date: Mon Dec  3 14:23:21 2018
New Revision: 348200

URL: http://llvm.org/viewvc/llvm-project?rev=348200&view=rev
Log:
[analyzer] Dump stable identifiers for objects under construction.

This continues the work that was started in r342313, which now gets applied to
object-under-construction tracking in C++. Makes it possible to debug
temporaries by dumping exploded graphs again.

Differential Revision: https://reviews.llvm.org/D54459

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/trunk/test/Analysis/dump_egraph.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=348200&r1=348199&r2=348200&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Dec  3 14:23:21 2018
@@ -138,9 +138,17 @@ public:
   const ConstructionContextItem &getItem() const { return Impl.first; }
   const LocationContext *getLocationContext() const { return Impl.second; }
 
+  ASTContext &getASTContext() const {
+    return getLocationContext()->getDecl()->getASTContext();
+  }
+
   void print(llvm::raw_ostream &OS, PrinterHelper *Helper, PrintingPolicy &PP) {
-    OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ','
-       << getItem().getKindAsString();
+    OS << "(LC" << getLocationContext()->getID() << ',';
+    if (const Stmt *S = getItem().getStmtOrNull())
+      OS << 'S' << S->getID(getASTContext());
+    else
+      OS << 'I' << getItem().getCXXCtorInitializer()->getID(getASTContext());
+    OS << ',' << getItem().getKindAsString();
     if (getItem().getKind() == ConstructionContextItem::ArgumentKind)
       OS << " #" << getItem().getIndex();
     OS << ") ";

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=348200&r1=348199&r2=348200&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Mon Dec  3 14:23:21 2018
@@ -2,14 +2,21 @@
 // RUN: cat %t.dot | FileCheck %s
 // REQUIRES: asserts
 
-
 struct S {
   ~S();
 };
 
+struct T {
+  S s;
+  T() : s() {}
+};
+
 void foo() {
   // Test that dumping symbols conjured on null statements doesn't crash.
-  S s;
+  T t;
 }
 
-// CHECK: conj_$0\{int, LC1, no stmt, #1\}
+// CHECK: (LC1,S{{[0-9]*}},construct into local variable) T t;\n : &t
+// CHECK: (LC2,I{{[0-9]*}},construct into member variable) s : &t-\>s
+// CHECK: conj_$5\{int, LC3, no stmt, #1\}
+




More information about the cfe-commits mailing list