[cfe-commits] r46759 - in /cfe/trunk/Analysis: GRConstants.cpp RValues.h ValueState.h

Ted Kremenek kremenek at apple.com
Tue Feb 5 11:35:18 PST 2008


Author: kremenek
Date: Tue Feb  5 13:35:18 2008
New Revision: 46759

URL: http://llvm.org/viewvc/llvm-project?rev=46759&view=rev
Log:
Added "batch" processing versions of Nodify and SetValue.  Created typedefs
for buffers for RValues and States.

Modified:
    cfe/trunk/Analysis/GRConstants.cpp
    cfe/trunk/Analysis/RValues.h
    cfe/trunk/Analysis/ValueState.h

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

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Tue Feb  5 13:35:18 2008
@@ -91,7 +91,7 @@
     const_iterator begin() const { return Impl.begin(); }
     const_iterator end() const { return Impl.end(); }
   };
-                                                              
+                                                                
 protected:
   /// G - the simulation graph.
   GraphTy& G;
@@ -183,6 +183,12 @@
     return SetValue(St, const_cast<Stmt*>(S), V);
   }
   
+  /// SetValue - This version of SetValue is used to batch process a set
+  ///  of different possible RValues and return a set of different states.
+  const StateTy::BufferTy& SetValue(StateTy St, Stmt* S,
+                                    const RValue::BufferTy& V,
+                                    StateTy::BufferTy& RetBuf);
+  
   StateTy SetValue(StateTy St, const LValue& LV, const RValue& V);
   
   inline RValue GetValue(const StateTy& St, Stmt* S) {
@@ -224,6 +230,10 @@
   
   void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, StateTy St);
   
+  /// Nodify - This version of Nodify is used to batch process a set of states.
+  ///  The states are not guaranteed to be unique.
+  void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy::BufferTy& SB);
+  
   /// Visit - Transfer function logic for all statements.  Dispatches to
   ///  other functions that handle specific kinds of statements.
   void Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst);
@@ -270,6 +280,18 @@
   return StateMgr.SetValue(St, S, isBlkExpr, V);
 }
 
+const GRConstants::StateTy::BufferTy&
+GRConstants::SetValue(StateTy St, Stmt* S, const RValue::BufferTy& RB,
+                      StateTy::BufferTy& RetBuf) {
+  
+  assert (RetBuf.empty());
+  
+  for (RValue::BufferTy::const_iterator I=RB.begin(), E=RB.end(); I!=E; ++I)
+    RetBuf.push_back(SetValue(St, S, *I));
+                     
+  return RetBuf;
+}
+
 GRConstants::StateTy
 GRConstants::SetValue(StateTy St, const LValue& LV, const RValue& V) {
   
@@ -473,8 +495,7 @@
   return M;
 }
 
-void GRConstants::Nodify(NodeSet& Dst, Stmt* S, GRConstants::NodeTy* Pred, 
-                         GRConstants::StateTy St) {
+void GRConstants::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, StateTy St) {
  
   // If the state hasn't changed, don't generate a new node.
   if (St == Pred->getState())
@@ -483,8 +504,14 @@
   Dst.Add(Builder->generateNode(S, St, Pred));
 }
 
-void GRConstants::VisitCast(Expr* CastE, Expr* E, GRConstants::NodeTy* Pred,
-                            GRConstants::NodeSet& Dst) {
+void GRConstants::Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred,
+                         const StateTy::BufferTy& SB) {
+  
+  for (StateTy::BufferTy::const_iterator I=SB.begin(), E=SB.end(); I!=E; ++I)
+    Nodify(Dst, S, Pred, *I);
+}
+
+void GRConstants::VisitCast(Expr* CastE, Expr* E, NodeTy* Pred, NodeSet& Dst) {
   
   QualType T = CastE->getType();
 
@@ -737,15 +764,14 @@
           if (isa<LValue>(V1)) {
             const LValue& L1 = cast<LValue>(V1);
             const LValue& L2 = cast<LValue>(V2);
-            St = SetValue(St, B, L1.EQ(ValMgr, L2));
+            Nodify(Dst, B, N2, SetValue(St, B, L1.EQ(ValMgr, L2)));
           }
           else {
             const NonLValue& R1 = cast<NonLValue>(V1);
             const NonLValue& R2 = cast<NonLValue>(V2);
-            St = SetValue(St, B, R1.EQ(ValMgr, R2));
+            Nodify(Dst, B, N2, SetValue(St, B, R1.EQ(ValMgr, R2)));
           }
           
-          Nodify(Dst, B, N2, St);
           break;
       }
     }

Modified: cfe/trunk/Analysis/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.h?rev=46759&r1=46758&r2=46759&view=diff

==============================================================================
--- cfe/trunk/Analysis/RValues.h (original)
+++ cfe/trunk/Analysis/RValues.h Tue Feb  5 13:35:18 2008
@@ -143,6 +143,10 @@
 public:
   ~RValue() {};
   
+  /// BufferTy - A temporary buffer to hold a set of RValues.
+  typedef llvm::SmallVector<RValue,5> BufferTy;
+
+  
   RValue Cast(ValueManager& ValMgr, Expr* CastExpr) const;
   
   unsigned getRawKind() const { return Kind; }

Modified: cfe/trunk/Analysis/ValueState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.h?rev=46759&r1=46758&r2=46759&view=diff

==============================================================================
--- cfe/trunk/Analysis/ValueState.h (original)
+++ cfe/trunk/Analysis/ValueState.h Tue Feb  5 13:35:18 2008
@@ -167,15 +167,13 @@
   ValueState() : Data(0) {}  
   void operator=(ValueStateImpl* D) { Data = D; }
   
-  // Accessors.
-  
+  // Accessors.  
   ValueStateImpl* getImpl() const { return Data; }
 
-
-  // Binding maps typedefs.
-  
-  typedef vstate::VariableBindingsTy VariableBindingsTy;
-  typedef vstate::ConstantNotEqTy    ConstantNotEqTy;
+  // Typedefs.
+  typedef vstate::VariableBindingsTy       VariableBindingsTy;
+  typedef vstate::ConstantNotEqTy          ConstantNotEqTy;
+  typedef llvm::SmallVector<ValueState,5>  BufferTy;
 
   // Iterators.
 





More information about the cfe-commits mailing list