public:
GRStmtNodeBuilder(GRStmtNodeBuilderImpl& nb, StateManagerTy& mgr) :
NB(nb), Mgr(mgr), Auditor(0), PurgingDeadSymbols(false),
- BuildSinks(false), HasGeneratedNode(false) {
+ BuildSinks(false), HasGeneratedNode(false),
+ PointKind(ProgramPoint::PostStmtKind) {
CleanedState = getLastNode()->getState();
}
return static_cast<NodeTy*>(NB.getLastNode());
}
- NodeTy*
- generateNode(Stmt* S, const StateTy* St, NodeTy* Pred,
- ProgramPoint::Kind K = ProgramPoint::PostStmtKind) {
-
+ NodeTy* generateNode(Stmt* S, const StateTy* St, NodeTy* Pred,
+ ProgramPoint::Kind K) {
HasGeneratedNode = true;
if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind;
return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, Pred, K));
}
- NodeTy*
- generateNode(Stmt* S, const StateTy* St,
- ProgramPoint::Kind K = ProgramPoint::PostStmtKind) {
-
+ NodeTy* generateNode(Stmt* S, const StateTy* St, NodeTy* Pred) {
+ return generateNode(S, St, Pred, PointKind);
+ }
+
+ NodeTy* generateNode(Stmt* S, const StateTy* St, ProgramPoint::Kind K) {
HasGeneratedNode = true;
if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind;
return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, K));
}
+ NodeTy* generateNode(Stmt* S, const StateTy* St) {
+ return generateNode(S, St, PointKind);
+ }
+
+
GRBlockCounter getBlockCounter() const {
return NB.getBlockCounter();
}
bool PurgingDeadSymbols;
bool BuildSinks;
bool HasGeneratedNode;
+ ProgramPoint::Kind PointKind;
};
class GRBranchNodeBuilderImpl {
class ProgramPoint {
public:
enum Kind { BlockEdgeKind=0, BlockEntranceKind, BlockExitKind,
- // Keep the following three together and in this order.
- PostStmtKind, PostLoadKind, PostPurgeDeadSymbolsKind };
+ // Keep the following four together and in this order.
+ PostStmtKind, PostLoadKind, PostStoreKind,
+ PostPurgeDeadSymbolsKind };
private:
std::pair<uintptr_t,uintptr_t> Data;
}
};
+class PostStore : public PostStmt {
+public:
+ PostStore(const Stmt* S) : PostStmt(S, PostLoadKind) {}
+
+ static bool classof(const ProgramPoint* Location) {
+ return Location->getKind() == PostStoreKind;
+ }
+};
+
class PostPurgeDeadSymbols : public PostStmt {
public:
PostPurgeDeadSymbols(const Stmt* S) : PostStmt(S, PostPurgeDeadSymbolsKind) {}
unsigned size = Dst.size();
SaveAndRestore<bool> OldSink(Builder->BuildSinks);
+ SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind);
SaveOr OldHasGen(Builder->HasGeneratedNode);
assert (!location.isUndef());
+ Builder->PointKind = ProgramPoint::PostStoreKind;
getTF().EvalStore(Dst, *this, *Builder, Ex, Pred, St, location, Val);
Ex->getType())), K);
}
+void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred,
+ const GRState* St, RVal location, RVal Val) {
+
+ NodeSet TmpDst;
+ EvalStore(TmpDst, StoreE, Pred, St, location, Val);
+
+ for (NodeSet::iterator I=TmpDst.begin(), E=TmpDst.end(); I!=E; ++I)
+ MakeNode(Dst, Ex, *I, (*I)->getState());
+}
+
const GRState* GRExprEngine::EvalLocation(Expr* Ex, NodeTy* Pred,
const GRState* St,
RVal location, bool isLoad) {
// Simulate the effects of a "store": bind the value of the RHS
// to the L-Value represented by the LHS.
- EvalStore(Dst, B, *I2, SetRVal(St, B, RightV), LeftV, RightV);
+ EvalStore(Dst, B, LHS, *I2, SetRVal(St, B, RightV), LeftV, RightV);
continue;
}
// Propagate undefined values (left-side).
if (V.isUndef()) {
- EvalStore(Dst, B, *I3, SetRVal(St, B, V), location, V);
+ EvalStore(Dst, B, LHS, *I3, SetRVal(St, B, V), location, V);
continue;
}
// Propagate unknown values (left and right-side).
if (RightV.isUnknown() || V.isUnknown()) {
- EvalStore(Dst, B, *I3, SetRVal(St, B, UnknownVal()), location,
+ EvalStore(Dst, B, LHS, *I3, SetRVal(St, B, UnknownVal()), location,
UnknownVal());
continue;
}
if (CheckDivideZero(B, St, *I3, RightV))
continue;
}
- else if (RightV.isUndef()) {
-
- // Propagate undefined values (right-side).
-
- EvalStore(Dst, B, *I3, SetRVal(St, B, RightV), location, RightV);
+ else if (RightV.isUndef()) {
+ // Propagate undefined values (right-side).
+ EvalStore(Dst, B, LHS, *I3, SetRVal(St, B, RightV), location, RightV);
continue;
}
continue;
}
- EvalStore(Dst, B, *I3, SetRVal(St, B, Result), location, Result);
+ EvalStore(Dst, B, LHS, *I3, SetRVal(St, B, Result), location, Result);
}
}
}