summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-12-03 22:23:21 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-12-03 22:23:21 +0000
commitca3ace55dc8b2269f73ed7b27ff42fe826d6c3e7 (patch)
tree2beb6a3bd8a01b30a88d640f73a9285e8c7dc378
parent057647d8783c01301a84bc09c9e5b667460c1ceb (diff)
downloadbcm5719-llvm-ca3ace55dc8b2269f73ed7b27ff42fe826d6c3e7.tar.gz
bcm5719-llvm-ca3ace55dc8b2269f73ed7b27ff42fe826d6c3e7.zip
[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 llvm-svn: 348200
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp12
-rw-r--r--clang/test/Analysis/dump_egraph.cpp13
2 files changed, 20 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index fa5a61971fc..648095c0497 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -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 << ") ";
diff --git a/clang/test/Analysis/dump_egraph.cpp b/clang/test/Analysis/dump_egraph.cpp
index 74133c54014..10e33a7523f 100644
--- a/clang/test/Analysis/dump_egraph.cpp
+++ b/clang/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\}
+
OpenPOWER on IntegriCloud