]> granicus.if.org Git - clang/commitdiff
Allow the 'Eng' entry in GRStateManager to be a (possibly null) pointer instead of...
authorTed Kremenek <kremenek@apple.com>
Fri, 11 Feb 2011 04:20:16 +0000 (04:20 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 11 Feb 2011 04:20:16 +0000 (04:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125362 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
lib/StaticAnalyzer/Core/GRState.cpp

index a2cbb20e7b1baa4579da94337b1e85b6777b6af1..4c5b94f307c56698929e27b09bcc0a1547c88911 100644 (file)
@@ -423,7 +423,7 @@ class GRStateManager {
   friend class ExprEngine; // FIXME: Remove.
 private:
   /// Eng - The SubEngine that owns this state manager.
-  SubEngine &Eng;
+  SubEngine *Eng; /* Can be null. */
 
   EnvironmentManager                   EnvMgr;
   llvm::OwningPtr<StoreManager>        StoreMgr;
@@ -461,7 +461,7 @@ public:
                  ConstraintManagerCreator CreateConstraintManager,
                  llvm::BumpPtrAllocator& alloc,
                  SubEngine &subeng)
-    : Eng(subeng),
+    : Eng(&subeng),
       EnvMgr(alloc),
       GDMFactory(alloc),
       svalBuilder(createSimpleSValBuilder(alloc, Ctx, *this)),
@@ -470,6 +470,19 @@ public:
     ConstraintMgr.reset((*CreateConstraintManager)(*this, subeng));
   }
 
+  GRStateManager(ASTContext& Ctx,
+                 StoreManagerCreator CreateStoreManager,
+                 ConstraintManager* ConstraintManagerPtr,
+                 llvm::BumpPtrAllocator& alloc)
+    : Eng(0),
+      EnvMgr(alloc),
+      GDMFactory(alloc),
+      svalBuilder(createSimpleSValBuilder(alloc, Ctx, *this)),
+      Alloc(alloc) {
+    StoreMgr.reset((*CreateStoreManager)(*this));
+    ConstraintMgr.reset(ConstraintManagerPtr);
+  }
+
   ~GRStateManager();
 
   const GRState *getInitialState(const LocationContext *InitLoc);
@@ -506,7 +519,7 @@ public:
 
   StoreManager& getStoreManager() { return *StoreMgr; }
   ConstraintManager& getConstraintManager() { return *ConstraintMgr; }
-  SubEngine& getOwningEngine() { return Eng; }
+  SubEngine* getOwningEngine() { return Eng; }
 
   const GRState* removeDeadBindings(const GRState* St,
                                     const StackFrameContext *LCtx,
index 5fddcec94c63ba5489d15f44d557a93cb5998825..0278a0d385fe34b369df54fcb0e5ca364cf6ef78 100644 (file)
@@ -94,8 +94,8 @@ const GRState *GRState::bindLoc(Loc LV, SVal V) const {
   const GRState *new_state = makeWithStore(new_store);
 
   const MemRegion *MR = LV.getAsRegion();
-  if (MR)
-    return Mgr.getOwningEngine().processRegionChange(new_state, MR);
+  if (MR && Mgr.getOwningEngine())
+    return Mgr.getOwningEngine()->processRegionChange(new_state, MR);
 
   return new_state;
 }
@@ -105,7 +105,9 @@ const GRState *GRState::bindDefault(SVal loc, SVal V) const {
   const MemRegion *R = cast<loc::MemRegionVal>(loc).getRegion();
   Store new_store = Mgr.StoreMgr->BindDefault(St, R, V);
   const GRState *new_state = makeWithStore(new_store);
-  return Mgr.getOwningEngine().processRegionChange(new_state, R);
+  return Mgr.getOwningEngine() ? 
+           Mgr.getOwningEngine()->processRegionChange(new_state, R) : 
+           new_state;
 }
 
 const GRState *GRState::InvalidateRegions(const MemRegion * const *Begin,
@@ -114,9 +116,9 @@ const GRState *GRState::InvalidateRegions(const MemRegion * const *Begin,
                                           StoreManager::InvalidatedSymbols *IS,
                                           bool invalidateGlobals) const {
   GRStateManager &Mgr = getStateManager();
-  SubEngine &Eng = Mgr.getOwningEngine();
-
-  if (Eng.wantsRegionChangeUpdate(this)) {
+  SubEngineEng = Mgr.getOwningEngine();
+  if (Eng && Eng->wantsRegionChangeUpdate(this)) {
     StoreManager::InvalidatedRegions Regions;
 
     Store new_store = Mgr.StoreMgr->InvalidateRegions(St, Begin, End,
@@ -125,9 +127,9 @@ const GRState *GRState::InvalidateRegions(const MemRegion * const *Begin,
                                                       &Regions);
     const GRState *new_state = makeWithStore(new_store);
 
-    return Eng.processRegionChanges(new_state,
-                                    &Regions.front(),
-                                    &Regions.back()+1);
+    return Eng->processRegionChanges(new_state,
+                                     &Regions.front(),
+                                     &Regions.back()+1);
   }
 
   Store new_store = Mgr.StoreMgr->InvalidateRegions(St, Begin, End,