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

Ted Kremenek kremenek at apple.com
Wed Jan 23 14:30:45 PST 2008


Author: kremenek
Date: Wed Jan 23 16:30:44 2008
New Revision: 46284

URL: http://llvm.org/viewvc/llvm-project?rev=46284&view=rev
Log:
some prettying of the GraphViz visualization of GRConstants analysis results.

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=46284&r1=46283&r2=46284&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Jan 23 16:30:44 2008
@@ -341,13 +341,16 @@
         Out << "Invalid"; break;
       
     case RValueMayEqualSetKind: {
-      Out << "MayEqual{";
       APSIntSetTy S = cast<RValueMayEqualSet>(this)->GetValues();
+      bool first = true;
 
-      for (APSIntSetTy::iterator I=S.begin(), E=S.end(); I!=E; ++I)
-        Out << ' ' << (*I).toString();
-
-      Out << " }";
+      for (APSIntSetTy::iterator I=S.begin(), E=S.end(); I!=E; ++I) {
+        if (first) first = false;
+        else Out << " | ";
+        
+        Out << (*I).toString();
+      }
+      
       break;
     }
       
@@ -720,10 +723,24 @@
 struct VISIBILITY_HIDDEN DOTGraphTraits<GRConstants::NodeTy*> :
   public DefaultDOTGraphTraits {
     
+ 
+  static std::string getNodeAttributes(void*, void*) {
+    return "fontname=\"monaco,fixed\", fontsize=\"11\""; 
+  }
+  
+  static void PrintKind(std::ostringstream& Out, ValueKey::Kind kind) {
+    switch (kind) {
+      case ValueKey::IsSubExp:  Out << "Sub-Expressions:\\l"; break;
+      case ValueKey::IsDecl:    Out << "Variables:\\l"; break;
+      case ValueKey::IsBlkExpr: Out << "Block-level Expressions:\\l"; break;
+      default: assert (false && "Unknown ValueKey type.");
+    }
+  }
+    
   static std::string getNodeLabel(const GRConstants::NodeTy* N, void*) {
     std::ostringstream Out;
-        
-    Out << "Vertex: " << (void*) N << '\n';
+
+    // Program Location.
     ProgramPoint Loc = N->getLocation();
     
     switch (Loc.getKind()) {
@@ -738,7 +755,7 @@
         
       case ProgramPoint::PostStmtKind: {
         const PostStmt& L = cast<PostStmt>(Loc);
-        Out << "Stmt: " << (void*) L.getStmt() << '\n';
+        Out << "(" << (void*) L.getStmt() << ") ";
         L.getStmt()->printPretty(Out);
         break;
       }
@@ -750,31 +767,47 @@
       }
     }
     
-    Out << "\n{";
+    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)
-        Out << '\n';
-      else
+      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 << ' ';
       
       if (ValueDecl* V = dyn_cast<ValueDecl>(I.getKey())) {
-        Out << "Decl: " << (void*) V << ", " << V->getName();          
+        Out << V->getName();          
       }
       else {
         Stmt* E = cast<Stmt>(I.getKey());
-        Out << "Stmt: " << (void*) E;
+        Out << " (" << (void*) E << ") ";
+        E->printPretty(Out);
       }
       
-      Out << " => ";
+      Out << " : ";
       I.getData().print(Out);
     }
     
-    Out << " }";
-    
+    Out << "\\l";
     return Out.str();
   }
 };





More information about the cfe-commits mailing list