[cfe-commits] r83934 - in /cfe/trunk: include/clang/Analysis/PathSensitive/AnalysisContext.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/RegionStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Oct 12 19:24:56 PDT 2009
Author: zhongxingxu
Date: Mon Oct 12 21:24:55 2009
New Revision: 83934
URL: http://llvm.org/viewvc/llvm-project?rev=83934&view=rev
Log:
Add an initial implementation of EnterStackFrame() to the StoreManager.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h
cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h?rev=83934&r1=83933&r2=83934&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h Mon Oct 12 21:24:55 2009
@@ -117,6 +117,8 @@
const Stmt *s)
: LocationContext(StackFrame, ctx, parent), CallSite(s) {}
+ Stmt const *getCallSite() const { return CallSite; }
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getAnalysisContext(), getParent(), CallSite);
}
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=83934&r1=83933&r2=83934&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Mon Oct 12 21:24:55 2009
@@ -32,6 +32,7 @@
class Expr;
class ObjCIvarDecl;
class SubRegionMap;
+class StackFrameContext;
class StoreManager {
protected:
@@ -157,6 +158,13 @@
return state;
}
+ /// EnterStackFrame - Let the StoreManager to do something when execution
+ /// engine is about to execute into a callee.
+ virtual const GRState *EnterStackFrame(const GRState *state,
+ const StackFrameContext *frame) {
+ assert(0 && "EnterStackFrame() is not supported in this Store Model.");
+ }
+
virtual void print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) = 0;
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=83934&r1=83933&r2=83934&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Oct 12 21:24:55 2009
@@ -353,6 +353,9 @@
void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
+ const GRState *EnterStackFrame(const GRState *state,
+ const StackFrameContext *frame);
+
//===------------------------------------------------------------------===//
// Region "extents".
//===------------------------------------------------------------------===//
@@ -1820,6 +1823,25 @@
state.setStore(store);
}
+GRState const *RegionStoreManager::EnterStackFrame(GRState const *state,
+ StackFrameContext const *frame) {
+ FunctionDecl const *FD = cast<FunctionDecl>(frame->getDecl());
+ CallExpr const *CE = cast<CallExpr>(frame->getCallSite());
+
+ FunctionDecl::param_const_iterator PI = FD->param_begin();
+
+ CallExpr::const_arg_iterator AI = CE->arg_begin(), AE = CE->arg_end();
+
+ // Copy the arg expression value to the arg variables.
+ for (; AI != AE; ++AI, ++PI) {
+ SVal ArgVal = state->getSVal(*AI);
+ MemRegion *R = MRMgr.getVarRegion(*PI, frame);
+ state = Bind(state, ValMgr.makeLoc(R), ArgVal);
+ }
+
+ return state;
+}
+
//===----------------------------------------------------------------------===//
// Utility methods.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list