From 2b1e6196e149ed81e59be6e1ad15cc90373e9ec1 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 llvm-svn: 328835 --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +- clang/lib/StaticAnalyzer/Core/MemRegion.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index d22cf82..51c6f25 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/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/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp index 1562ff1..b735f5a 100644 --- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/clang/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.7.4