]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix dumping for SymbolConjured conjured at no particular statement.
authorArtem Dergachev <artem.dergachev@gmail.com>
Mon, 22 Oct 2018 20:11:10 +0000 (20:11 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Mon, 22 Oct 2018 20:11:10 +0000 (20:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/SymbolManager.cpp
test/Analysis/dump_egraph.cpp [new file with mode: 0644]

index ec1224e52b928a1835c2aa57accfa0e3bbd00b70..4129191dd826958f1d2372a5380803cb77b9fdf4 100644 (file)
@@ -83,10 +83,13 @@ void SymbolCast::dumpToStream(raw_ostream &os) const {
 }
 
 void SymbolConjured::dumpToStream(raw_ostream &os) const {
-  os << "conj_$" << getSymbolID() << '{' << T.getAsString()
-    << ", LC" << LCtx->getID() << ", S" << S->getID(
-      LCtx->getDecl()->getASTContext()) << ", #" << Count
-    << '}';
+  os << "conj_$" << getSymbolID() << '{' << T.getAsString() << ", LC"
+     << LCtx->getID();
+  if (S)
+    os << ", S" << S->getID(LCtx->getDecl()->getASTContext());
+  else
+    os << ", no stmt";
+  os << ", #" << Count << '}';
 }
 
 void SymbolDerived::dumpToStream(raw_ostream &os) const {
diff --git a/test/Analysis/dump_egraph.cpp b/test/Analysis/dump_egraph.cpp
new file mode 100644 (file)
index 0000000..74133c5
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot %s
+// RUN: cat %t.dot | FileCheck %s
+// REQUIRES: asserts
+
+
+struct S {
+  ~S();
+};
+
+void foo() {
+  // Test that dumping symbols conjured on null statements doesn't crash.
+  S s;
+}
+
+// CHECK: conj_$0\{int, LC1, no stmt, #1\}