From: Ted Kremenek Date: Tue, 5 Feb 2008 19:35:18 +0000 (+0000) Subject: Added "batch" processing versions of Nodify and SetValue. Created typedefs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cba2e4302cb524e871bab39b44b0f724d8f7d5ef;p=clang Added "batch" processing versions of Nodify and SetValue. Created typedefs for buffers for RValues and States. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46759 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp index a156cdb261..69defc8cad 100644 --- a/Analysis/GRConstants.cpp +++ b/Analysis/GRConstants.cpp @@ -91,7 +91,7 @@ public: 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 @@ public: return SetValue(St, const_cast(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 @@ public: 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 @@ GRConstants::SetValue(StateTy St, Stmt* S, const RValue& V) { 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 @@ GRConstants::StateTy GRConstants::RemoveDeadBindings(Stmt* Loc, StateTy M) { 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 @@ void GRConstants::Nodify(NodeSet& Dst, Stmt* S, GRConstants::NodeTy* Pred, 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 @@ void GRConstants::VisitBinaryOperator(BinaryOperator* B, if (isa(V1)) { const LValue& L1 = cast(V1); const LValue& L2 = cast(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(V1); const NonLValue& R2 = cast(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; } } diff --git a/Analysis/RValues.h b/Analysis/RValues.h index b5b7873f63..c69a70a52d 100644 --- a/Analysis/RValues.h +++ b/Analysis/RValues.h @@ -143,6 +143,10 @@ protected: public: ~RValue() {}; + /// BufferTy - A temporary buffer to hold a set of RValues. + typedef llvm::SmallVector BufferTy; + + RValue Cast(ValueManager& ValMgr, Expr* CastExpr) const; unsigned getRawKind() const { return Kind; } diff --git a/Analysis/ValueState.h b/Analysis/ValueState.h index 984901fd79..10abdceb32 100644 --- a/Analysis/ValueState.h +++ b/Analysis/ValueState.h @@ -167,15 +167,13 @@ public: 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 BufferTy; // Iterators.