[cfe-commits] r46326 - /cfe/trunk/Analysis/GRConstants.cpp

Ted Kremenek kremenek at apple.com
Thu Jan 24 14:27:20 PST 2008


Author: kremenek
Date: Thu Jan 24 16:27:20 2008
New Revision: 46326

URL: http://llvm.org/viewvc/llvm-project?rev=46326&view=rev
Log:
More cleanups to pretty-printing of states in GraphViz output.

Modified:
    cfe/trunk/Analysis/GRConstants.cpp

Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46326&r1=46325&r2=46326&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Thu Jan 24 16:27:20 2008
@@ -753,7 +753,14 @@
     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 @@
 template<>
 struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
   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 @@
     }
   }
     
+  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<ValueDecl>(I.getKey()))
+        Out << V->getName();          
+      else {
+        Stmt* E = cast<Stmt>(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 @@
         
       case ProgramPoint::PostStmtKind: {
         const PostStmt& L = cast<PostStmt>(Loc);
-        Out << "(" << (void*) L.getStmt() << ") ";
+        Out << L.getStmt()->getStmtClassName() << ':' 
+            << (void*) L.getStmt() << ' ';
+        
         L.getStmt()->printPretty(Out);
         break;
       }
@@ -1117,44 +1157,10 @@
     
     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<ValueDecl>(I.getKey())) {
-        Out << V->getName();          
-      }
-      else {
-        Stmt* E = cast<Stmt>(I.getKey());
-        Out << " (" << (void*) E << ") ";
-        E->printPretty(Out);
-      }
-      
-      Out << " : ";
-      I.getData().print(Out);
-    }
-    
     Out << "\\l";
     return Out.str();
   }





More information about the cfe-commits mailing list