[cfe-commits] r125362 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h lib/StaticAnalyzer/Core/GRState.cpp

Ted Kremenek kremenek at apple.com
Thu Feb 10 20:20:16 PST 2011


Author: kremenek
Date: Thu Feb 10 22:20:16 2011
New Revision: 125362

URL: http://llvm.org/viewvc/llvm-project?rev=125362&view=rev
Log:
Allow the 'Eng' entry in GRStateManager to be a (possibly null) pointer instead of a reference.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
    cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h?rev=125362&r1=125361&r2=125362&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h Thu Feb 10 22:20:16 2011
@@ -423,7 +423,7 @@
   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 @@
                  ConstraintManagerCreator CreateConstraintManager,
                  llvm::BumpPtrAllocator& alloc,
                  SubEngine &subeng)
-    : Eng(subeng),
+    : Eng(&subeng),
       EnvMgr(alloc),
       GDMFactory(alloc),
       svalBuilder(createSimpleSValBuilder(alloc, Ctx, *this)),
@@ -470,6 +470,19 @@
     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 @@
 
   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,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp?rev=125362&r1=125361&r2=125362&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp Thu Feb 10 22:20:16 2011
@@ -94,8 +94,8 @@
   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 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 @@
                                           StoreManager::InvalidatedSymbols *IS,
                                           bool invalidateGlobals) const {
   GRStateManager &Mgr = getStateManager();
-  SubEngine &Eng = Mgr.getOwningEngine();
-
-  if (Eng.wantsRegionChangeUpdate(this)) {
+  SubEngine* Eng = Mgr.getOwningEngine();
+ 
+  if (Eng && Eng->wantsRegionChangeUpdate(this)) {
     StoreManager::InvalidatedRegions Regions;
 
     Store new_store = Mgr.StoreMgr->InvalidateRegions(St, Begin, End,
@@ -125,9 +127,9 @@
                                                       &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,





More information about the cfe-commits mailing list