From: Artem Dergachev Date: Mon, 22 Oct 2018 20:11:10 +0000 (+0000) Subject: [analyzer] Fix dumping for SymbolConjured conjured at no particular statement. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b5257f27c1c13aaded27a0ef7bbd3ff7aedf666;p=clang [analyzer] Fix dumping for SymbolConjured conjured at no particular statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344944 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/SymbolManager.cpp b/lib/StaticAnalyzer/Core/SymbolManager.cpp index ec1224e52b..4129191dd8 100644 --- a/lib/StaticAnalyzer/Core/SymbolManager.cpp +++ b/lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -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 index 0000000000..74133c5401 --- /dev/null +++ b/test/Analysis/dump_egraph.cpp @@ -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\}