From: Ted Kremenek Date: Thu, 24 Jan 2008 22:27:20 +0000 (+0000) Subject: More cleanups to pretty-printing of states in GraphViz output. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ff731dc1f22e3779485620411457caecb8a12f6;p=clang More cleanups to pretty-printing of states in GraphViz output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp index f35fe813d0..50be690077 100644 --- a/Analysis/GRConstants.cpp +++ b/Analysis/GRConstants.cpp @@ -753,7 +753,14 @@ GRConstants::StateTy GRConstants::SetValue(StateTy St, Stmt* S, StateCleaned = true; } - bool isBlkExpr = S == CurrentStmt && getCFG().isBlkExpr(S); + bool isBlkExpr = false; + + if (S == CurrentStmt) { + isBlkExpr = getCFG().isBlkExpr(S); + + if (!isBlkExpr) + return St; + } return V.isValid() ? StateMgr.Add(St, ValueKey(S,isBlkExpr), V) : St; @@ -1075,8 +1082,8 @@ namespace llvm { template<> struct VISIBILITY_HIDDEN DOTGraphTraits : public DefaultDOTGraphTraits { - - static void PrintKind(std::ostringstream& Out, ValueKey::Kind kind) { + + static void PrintKindLabel(std::ostream& Out, ValueKey::Kind kind) { switch (kind) { case ValueKey::IsSubExp: Out << "Sub-Expressions:\\l"; break; case ValueKey::IsDecl: Out << "Variables:\\l"; break; @@ -1085,6 +1092,37 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : } } + static void PrintKind(std::ostream& Out, GRConstants::StateTy M, + ValueKey::Kind kind, bool isFirstGroup = false) { + bool isFirst = true; + + for (GRConstants::StateTy::iterator I=M.begin(), E=M.end();I!=E;++I) { + if (I.getKey().getKind() != kind) + continue; + + if (isFirst) { + if (!isFirstGroup) Out << "\\l\\l"; + PrintKindLabel(Out, kind); + isFirst = false; + } + else + Out << "\\l"; + + Out << ' '; + + if (ValueDecl* V = dyn_cast(I.getKey())) + Out << V->getName(); + else { + Stmt* E = cast(I.getKey()); + Out << " (" << (void*) E << ") "; + E->printPretty(Out); + } + + Out << " : "; + I.getData().print(Out); + } + } + static std::string getNodeLabel(const GRConstants::NodeTy* N, void*) { std::ostringstream Out; @@ -1103,7 +1141,9 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : case ProgramPoint::PostStmtKind: { const PostStmt& L = cast(Loc); - Out << "(" << (void*) L.getStmt() << ") "; + Out << L.getStmt()->getStmtClassName() << ':' + << (void*) L.getStmt() << ' '; + L.getStmt()->printPretty(Out); break; } @@ -1117,44 +1157,10 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : Out << "\\|"; - GRConstants::StateTy M = N->getState(); - bool isFirst = true; - ValueKey::Kind kind; - - for (GRConstants::StateTy::iterator I=M.begin(), E=M.end(); I!=E; ++I) { - if (!isFirst) { - ValueKey::Kind newKind = I.getKey().getKind(); - - if (newKind != kind) { - Out << "\\l\\l"; - PrintKind(Out, newKind); - } - else - Out << "\\l"; - - kind = newKind; - } - else { - kind = I.getKey().getKind(); - PrintKind(Out, kind); - isFirst = false; - } - - Out << ' '; + PrintKind(Out, N->getState(), ValueKey::IsDecl, true); + PrintKind(Out, N->getState(), ValueKey::IsBlkExpr); + PrintKind(Out, N->getState(), ValueKey::IsSubExp); - if (ValueDecl* V = dyn_cast(I.getKey())) { - Out << V->getName(); - } - else { - Stmt* E = cast(I.getKey()); - Out << " (" << (void*) E << ") "; - E->printPretty(Out); - } - - Out << " : "; - I.getData().print(Out); - } - Out << "\\l"; return Out.str(); }