[cfe-commits] r49826 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 16 16:05:52 PDT 2008
Author: kremenek
Date: Wed Apr 16 18:05:51 2008
New Revision: 49826
URL: http://llvm.org/viewvc/llvm-project?rev=49826&view=rev
Log:
Handle ReturnStmts by dispatching to "EvalReturn" in the transfer function object.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=49826&r1=49825&r2=49826&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Wed Apr 16 18:05:51 2008
@@ -602,13 +602,10 @@
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);
};
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=49826&r1=49825&r2=49826&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Wed Apr 16 18:05:51 2008
@@ -64,13 +64,13 @@
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.
@@ -88,6 +88,14 @@
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
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=49826&r1=49825&r2=49826&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Apr 16 18:05:51 2008
@@ -708,8 +708,8 @@
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.");
@@ -718,7 +718,7 @@
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.
@@ -1456,15 +1456,31 @@
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()) {
@@ -1494,11 +1510,14 @@
}
}
- 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);
}
//===----------------------------------------------------------------------===//
@@ -1649,7 +1668,7 @@
// 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;
@@ -1799,7 +1818,7 @@
}
// 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;
}
}
More information about the cfe-commits
mailing list