[cfe-commits] r83934 - in /cfe/trunk: include/clang/Analysis/PathSensitive/AnalysisContext.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/RegionStore.cpp

Ted Kremenek kremenek at apple.com
Mon Oct 12 21:30:55 PDT 2009


Hi Zhongxing,

It seems to me that RegionStoreManager::EnterStackFrame() could just  
be the implementation for StoreManager::EnterStackFrame().  There's  
nothing about RegionStoreManager::EnterStackFrame() that is specific  
to RegionStoreManager. You then wouldn't need to have the unpleasant  
assert(0) in StoreManager::EnterStackFrame(), and then it would work  
for both RegionStoreManager and BasicStoreManager.

On Oct 12, 2009, at 7:24 PM, Zhongxing Xu wrote:

> 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;
> +}
> +





More information about the cfe-commits mailing list