[PATCH] D54459: [analyzer] Dump reproducible identifiers for objects under construction.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 3 14:26:31 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC348200: [analyzer] Dump stable identifiers for objects under construction. (authored by dergachev, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54459/new/

https://reviews.llvm.org/D54459

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/dump_egraph.cpp


Index: test/Analysis/dump_egraph.cpp
===================================================================
--- test/Analysis/dump_egraph.cpp
+++ test/Analysis/dump_egraph.cpp
@@ -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\}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -138,9 +138,17 @@
   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 << ") ";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54459.176480.patch
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181203/235e0c67/attachment-0001.bin>


More information about the cfe-commits mailing list