r209842 - Thread Safety Analysis: minor changes to TIL pretty-printing.

DeLesley Hutchins delesley at google.com
Thu May 29 13:28:54 PDT 2014


Author: delesley
Date: Thu May 29 15:28:53 2014
New Revision: 209842

URL: http://llvm.org/viewvc/llvm-project?rev=209842&view=rev
Log:
Thread Safety Analysis: minor changes to TIL pretty-printing.

Modified:
    cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
    cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=209842&r1=209841&r2=209842&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Thu May 29 15:28:53 2014
@@ -364,6 +364,7 @@ public:
   // Let-variable, function parameter, or self-variable
   enum VariableKind {
     VK_Let,
+    VK_LetBB,
     VK_Fun,
     VK_SFun
   };
@@ -388,6 +389,7 @@ public:
   unsigned getID() const { return Id; }
   unsigned getBlockID() const { return BlockID; }
 
+  void setName(StringRef S) { Name = S; }
   void setID(unsigned Bid, unsigned I) {
     BlockID = static_cast<unsigned short>(Bid);
     Id = static_cast<unsigned short>(I);
@@ -1432,11 +1434,13 @@ public:
 
   // Add a new argument.  V must define a phi-node.
   void addArgument(Variable *V) {
+    V->setKind(Variable::VK_LetBB);
     Args.reserveCheck(1, Arena);
     Args.push_back(V);
   }
   // Add a new instruction.
   void addInstruction(Variable *V) {
+    V->setKind(Variable::VK_LetBB);
     Instrs.reserveCheck(1, Arena);
     Instrs.push_back(V);
   }

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h?rev=209842&r1=209841&r2=209842&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h Thu May 29 15:28:53 2014
@@ -475,9 +475,10 @@ template <typename Self, typename Stream
 class PrettyPrinter {
 private:
   bool Verbose;  // Print out additional information
+  bool Cleanup;  // Omit redundant decls.
 
 public:
-  PrettyPrinter(bool V = false) : Verbose(V) { }
+  PrettyPrinter(bool V = false, bool C = true) : Verbose(V), Cleanup(C) { }
 
   static void print(SExpr *E, StreamType &SS) {
     Self printer;
@@ -491,17 +492,6 @@ protected:
     SS << "\n";
   }
 
-  void printBlockLabel(StreamType & SS, BasicBlock *BB, unsigned index) {
-    if (!BB) {
-      SS << "BB_null";
-      return;
-    }
-    SS << "BB_";
-    SS << BB->blockID();
-    SS << ":";
-    SS << index;
-  }
-
   // TODO: further distinguish between binary operations.
   static const unsigned Prec_Atom = 0;
   static const unsigned Prec_Postfix = 1;
@@ -554,6 +544,17 @@ protected:
     return Prec_MAX;
   }
 
+  void printBlockLabel(StreamType & SS, BasicBlock *BB, unsigned index) {
+    if (!BB) {
+      SS << "BB_null";
+      return;
+    }
+    SS << "BB_";
+    SS << BB->blockID();
+    SS << ":";
+    SS << index;
+  }
+
   void printSExpr(SExpr *E, StreamType &SS, unsigned P) {
     if (!E) {
       self()->printNull(SS);
@@ -683,20 +684,17 @@ protected:
   }
 
   void printVariable(Variable *V, StreamType &SS, bool IsVarDecl = false) {
-    SExpr* E = nullptr;
-    if (!IsVarDecl) {
-      E = getCanonicalVal(V);
+    if (!IsVarDecl && Cleanup) {
+      SExpr* E = getCanonicalVal(V);
       if (E != V) {
         printSExpr(E, SS, Prec_Atom);
-        if (Verbose) {
-          SS << " /*";
-          SS << V->name() << V->getBlockID() << "_" << V->getID();
-          SS << "*/";
-        }
         return;
       }
     }
-    SS << V->name() << V->getBlockID() << "_" << V->getID();
+    if (V->kind() == Variable::VK_LetBB)
+      SS << V->name() << V->getBlockID() << "_" << V->getID();
+    else
+      SS << V->name() << V->getID();
   }
 
   void printFunction(Function *E, StreamType &SS, unsigned sugared = 0) {





More information about the cfe-commits mailing list