[PATCH] D54459: [analyzer] Dump reproducible identifiers for objects under construction.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 12 17:46:03 PST 2018
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, baloghadamsoftware.
This continues the work that was started in https://reviews.llvm.org/D51826, which now gets applied to object-under-construction tracking for C++.
Repository:
rC Clang
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.173800.patch
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181113/df2d2b19/attachment.bin>
More information about the cfe-commits
mailing list