From 8226258a9e215b7ae7f849a277feb404c8e26a35 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Mon, 3 Dec 2018 22:23:21 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348200 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/ExprEngine.cpp | 12 ++++++++++-- test/Analysis/dump_egraph.cpp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index fa5a61971f..648095c049 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/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/test/Analysis/dump_egraph.cpp b/test/Analysis/dump_egraph.cpp index 74133c5401..10e33a7523 100644 --- a/test/Analysis/dump_egraph.cpp +++ b/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\} + -- 2.40.0