TF->EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred);
}
- void VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
+ void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
RVal TargetLV, RVal Val);
- void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
- RVal TargetLV, RVal Val) {
- TF->EvalStore(Dst, *this, *Builder, E, Pred, St, TargetLV, Val);
- }
+ void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred);
ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
};
GRExprEngine& Engine,
GRStmtNodeBuilder<ValueState>& Builder,
CallExpr* CE, LVal L,
- ExplodedNode<ValueState>* Pred) = 0;
+ ExplodedNode<ValueState>* Pred) {}
virtual void EvalObjCMessageExpr(ExplodedNodeSet<ValueState>& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder<ValueState>& Builder,
ObjCMessageExpr* ME,
- ExplodedNode<ValueState>* Pred) = 0;
+ ExplodedNode<ValueState>* Pred) {}
// Stores.
virtual void EvalEndPath(GRExprEngine& Engine,
GREndPathNodeBuilder<ValueState>& Builder) {}
+
+ // Return statements.
+
+ virtual void EvalReturn(ExplodedNodeSet<ValueState>& Dst,
+ GRExprEngine& Engine,
+ GRStmtNodeBuilder<ValueState>& Builder,
+ ReturnStmt* S,
+ ExplodedNode<ValueState>* Pred) {}
};
} // end clang namespace
MakeNode(Dst, D, Pred, SetBlkExprRVal(St, D, Y));
}
-void GRExprEngine::VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred,
- ValueState* St, RVal TargetLV, RVal Val) {
+void GRExprEngine::EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred,
+ ValueState* St, RVal TargetLV, RVal Val) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
assert (!TargetLV.isUndef());
- EvalStore(Dst, E, Pred, St, TargetLV, Val);
+ TF->EvalStore(Dst, *this, *Builder, 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.
VisitAsmStmtHelperInputs(A, I, E, *NI, Dst);
}
+void GRExprEngine::EvalReturn(NodeSet& Dst, ReturnStmt* S, NodeTy* Pred) {
+ assert (Builder && "GRStmtNodeBuilder must be defined.");
+
+ unsigned size = Dst.size();
+ SaveAndRestore<bool> OldSink(Builder->BuildSinks);
+
+ TF->EvalReturn(Dst, *this, *Builder, S, Pred);
+
+ // 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, S, Pred, GetState(Pred));
+}
+
void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
Expr* R = S->getRetValue();
if (!R) {
- Dst.Add(Pred);
+ EvalReturn(Dst, S, Pred);
return;
}
-
+
+ NodeSet DstRet;
QualType T = R->getType();
if (T->isPointerLikeType()) {
}
}
- Dst.Add(*I);
+ DstRet.Add(*I);
}
}
else
- Visit(R, Pred, Dst);
+ Visit(R, Pred, DstRet);
+
+ for (NodeSet::iterator I=DstRet.begin(), E=DstRet.end(); I!=E; ++I)
+ EvalReturn(Dst, S, *I);
}
//===----------------------------------------------------------------------===//
// Simulate the effects of a "store": bind the value of the RHS
// to the L-Value represented by the LHS.
- VisitStore(Dst, B, N2, SetRVal(St, B, RightV),
+ EvalStore(Dst, B, N2, SetRVal(St, B, RightV),
LeftV, RightV);
continue;
}
// St = SetRVal(SetRVal(St, B, Result), LeftLV, Result);
- VisitStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
+ EvalStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
continue;
}
}