From d05cde1c10da8f3a294d101631d879a9d607e271 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Thu, 29 Mar 2018 22:07:58 +0000 Subject: [PATCH] [analyzer] Better pretty-printing of regions in exploded graph Differential Revision: https://reviews.llvm.org/D45010 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328835 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +- lib/StaticAnalyzer/Core/MemRegion.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index d22cf82963..51c6f25e98 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2482,7 +2482,7 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D, assert(Ex->isGLValue() || VD->getType()->isVoidType()); const LocationContext *LocCtxt = Pred->getLocationContext(); const Decl *D = LocCtxt->getDecl(); - const auto *MD = D ? dyn_cast(D) : nullptr; + const auto *MD = dyn_cast_or_null(D); const auto *DeclRefEx = dyn_cast(Ex); Optional> VInfo; diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp index 1562ff1193..b735f5ab56 100644 --- a/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -430,7 +430,7 @@ void BlockDataRegion::dumpToStream(raw_ostream &os) const { for (BlockDataRegion::referenced_vars_iterator I = referenced_vars_begin(), E = referenced_vars_end(); I != E; ++I) - os << "(" << I.getCapturedRegion() << "," << + os << "(" << I.getCapturedRegion() << "<-" << I.getOriginalRegion() << ") "; os << '}'; } @@ -483,7 +483,12 @@ void SymbolicRegion::dumpToStream(raw_ostream &os) const { } void VarRegion::dumpToStream(raw_ostream &os) const { - os << *cast(D); + const auto *VD = cast(D); + if (const auto *ID = VD->getIdentifier()) { + os << ID->getName(); + } else { + os << "VarRegion{" << static_cast(this) << '}'; + } } LLVM_DUMP_METHOD void RegionRawOffset::dump() const { -- 2.40.0