aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngine.h7
-rw-r--r--include/clang/Analysis/PathSensitive/GRTransferFuncs.h11
-rw-r--r--lib/Analysis/GRExprEngine.cpp23
3 files changed, 34 insertions, 7 deletions
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index 0d8dfb3202..f5ab33baaa 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -602,11 +602,12 @@ protected:
TF->EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred);
}
+ void VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
+ LVal TargetLV, RVal Val);
+
void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
LVal TargetLV, RVal Val) {
-
- assert (Builder && "GRStmtNodeBuilder must be defined.");
- MakeNode(Dst, E, Pred, SetRVal(St, TargetLV, Val));
+ TF->EvalStore(Dst, *this, *Builder, E, Pred, St, TargetLV, Val);
}
ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index 2242a13dbd..ced5e8f659 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -32,7 +32,7 @@ public:
return NULL;
}
- virtual void RegisterChecks(GRExprEngine& Eng) {}
+ virtual void RegisterChecks(GRExprEngine& Eng);
// Casts.
@@ -72,6 +72,15 @@ public:
ObjCMessageExpr* ME,
ExplodedNode<ValueState>* Pred) = 0;
+ // Stores.
+
+ virtual void EvalStore(ExplodedNodeSet<ValueState>& Dst,
+ GRExprEngine& Engine,
+ GRStmtNodeBuilder<ValueState>& Builder,
+ Expr* E, ExplodedNode<ValueState>* Pred,
+ ValueState* St, LVal TargetLV, RVal Val) {}
+
+
// End-of-path.
virtual void EvalEndPath(GRExprEngine& Engine,
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 9c6a37dbad..72bae32231 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -689,7 +689,7 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
}
//===----------------------------------------------------------------------===//
-// Transfer functions: DeclRefExprs (loads, getting l-values).
+// Transfer functions: Loads and stores.
//===----------------------------------------------------------------------===//
void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* D, NodeTy* Pred, NodeSet& Dst){
@@ -708,6 +708,23 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* D, NodeTy* Pred, NodeSet& Dst){
MakeNode(Dst, D, Pred, SetBlkExprRVal(St, D, Y));
}
+void GRExprEngine::VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred,
+ ValueState* St, LVal TargetLV, RVal Val) {
+
+ assert (Builder && "GRStmtNodeBuilder must be defined.");
+
+ unsigned size = Dst.size();
+ SaveAndRestore<bool> OldSink(Builder->BuildSinks);
+
+ EvalStore(Dst, E, Pred, St, TargetLV, Val);
+
+ // Handle the case where no nodes where generated. Auto-generate that
+ // contains the updated state if we aren't generating sinks.
+
+ if (!Builder->BuildSinks && Dst.size() == size)
+ MakeNode(Dst, E, Pred, SetRVal(St, TargetLV, Val));
+}
+
//===----------------------------------------------------------------------===//
// Transfer function: Function calls.
//===----------------------------------------------------------------------===//
@@ -1637,7 +1654,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Simulate the effects of a "store": bind the value of the RHS
// to the L-Value represented by the LHS.
- EvalStore(Dst, B, N2, SetRVal(St, B, RightV),
+ VisitStore(Dst, B, N2, SetRVal(St, B, RightV),
cast<LVal>(LeftV), RightV);
// St = SetRVal(SetRVal(St, B, RightV), cast<LVal>(LeftV), RightV);
@@ -1788,7 +1805,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
}
// St = SetRVal(SetRVal(St, B, Result), LeftLV, Result);
- EvalStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
+ VisitStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
continue;
}
}