[cfe-commits] r73740 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Environment.h include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/SVals.h lib/Analysis/BasicObjCFoundationChecks.cpp lib/Analysis/BasicObjCFoundationChecks.h lib/Analysis/BugReporter.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/Environment.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/GRExprEngineInternalChecks.cpp lib/Analysis/GRSimpleVals.cpp lib/Analysis/GRTransferFuncs.cpp lib/Analysis/SVals.cpp

Ted Kremenek kremenek at apple.com
Thu Jun 18 16:58:37 PDT 2009


Author: kremenek
Date: Thu Jun 18 18:58:37 2009
New Revision: 73740

URL: http://llvm.org/viewvc/llvm-project?rev=73740&view=rev
Log:
Move clients over from using GRStateManager::BindXXX and friends to
GRState->bindXXX and friends (and constify some arguments along the way).

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
    cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
    cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h
    cfe/trunk/lib/Analysis/BugReporter.cpp
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/Environment.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
    cfe/trunk/lib/Analysis/GRSimpleVals.cpp
    cfe/trunk/lib/Analysis/GRTransferFuncs.cpp
    cfe/trunk/lib/Analysis/SVals.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h Thu Jun 18 18:58:37 2009
@@ -35,7 +35,7 @@
   friend class EnvironmentManager;
   
   // Type definitions.
-  typedef llvm::ImmutableMap<Stmt*,SVal> BindingsTy;
+  typedef llvm::ImmutableMap<const Stmt*,SVal> BindingsTy;
 
   // Data.
   BindingsTy SubExprBindings;
@@ -54,25 +54,25 @@
   beb_iterator beb_begin() const { return BlkExprBindings.begin(); }
   beb_iterator beb_end() const { return BlkExprBindings.end(); }      
   
-  SVal LookupSubExpr(Stmt* E) const {
+  SVal LookupSubExpr(const Stmt* E) const {
     const SVal* X = SubExprBindings.lookup(cast<Expr>(E));
     return X ? *X : UnknownVal();
   }
   
-  SVal LookupBlkExpr(Stmt* E) const {
+  SVal LookupBlkExpr(const Stmt* E) const {
     const SVal* X = BlkExprBindings.lookup(E);
     return X ? *X : UnknownVal();
   }
   
-  SVal LookupExpr(Stmt* E) const {
+  SVal LookupExpr(const Stmt* E) const {
     const SVal* X = SubExprBindings.lookup(E);
     if (X) return *X;
     X = BlkExprBindings.lookup(E);
     return X ? *X : UnknownVal();
   }
   
-  SVal GetSVal(Stmt* Ex, BasicValueFactory& BasicVals) const;
-  SVal GetBlkExprSVal(Stmt* Ex, BasicValueFactory& BasicVals) const; 
+  SVal GetSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const;
+  SVal GetBlkExprSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const; 
   
   /// Profile - Profile the contents of an Environment object for use
   ///  in a FoldingSet.
@@ -108,19 +108,19 @@
   ///  removed.  This method only removes bindings for block-level expressions.
   ///  Using this method on a non-block level expression will return the
   ///  same environment object.
-  Environment RemoveBlkExpr(const Environment& Env, Stmt* E) {
+  Environment RemoveBlkExpr(const Environment& Env, const Stmt* E) {
     return Environment(Env.SubExprBindings, F.Remove(Env.BlkExprBindings, E));
   }
   
-  Environment RemoveSubExpr(const Environment& Env, Stmt* E) {
+  Environment RemoveSubExpr(const Environment& Env, const Stmt* E) {
     return Environment(F.Remove(Env.SubExprBindings, E), Env.BlkExprBindings);
   }
   
-  Environment AddBlkExpr(const Environment& Env, Stmt* E, SVal V) {
+  Environment AddBlkExpr(const Environment& Env, const Stmt *E, SVal V) {
     return Environment(Env.SubExprBindings, F.Add(Env.BlkExprBindings, E, V));
   }
   
-  Environment AddSubExpr(const Environment& Env, Stmt* E, SVal V) {
+  Environment AddSubExpr(const Environment& Env, const Stmt *E, SVal V) {
     return Environment(F.Add(Env.SubExprBindings, E, V), Env.BlkExprBindings);
   }
   
@@ -135,7 +135,7 @@
     return Environment(F.GetEmptyMap(), F.GetEmptyMap());
   }
   
-  Environment BindExpr(const Environment& Env, Stmt* E, SVal V,
+  Environment BindExpr(const Environment& Env, const Stmt* E, SVal V,
                        bool isBlkExpr, bool Invalidate);
 
   Environment

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Thu Jun 18 18:58:37 2009
@@ -202,10 +202,10 @@
   // Binding and retrieving values to/from the environment and symbolic store.
   //==---------------------------------------------------------------------==//
   
-  const GRState *bindExpr(Stmt* Ex, SVal V, bool isBlkExpr,
+  const GRState *bindExpr(const Stmt* Ex, SVal V, bool isBlkExpr,
                           bool Invalidate) const;
   
-  const GRState *bindExpr(Stmt* Ex, SVal V, bool Invalidate = true) const;  
+  const GRState *bindExpr(const Stmt* Ex, SVal V, bool Invalidate = true) const;  
   
   const GRState *bindLoc(Loc location, SVal V) const;
   
@@ -217,11 +217,11 @@
   
   const llvm::APSInt *getSymVal(SymbolRef sym) const;
 
-  SVal getSVal(Expr* Ex) const;
+  SVal getSVal(const Stmt* Ex) const;
   
-  SVal getBlkExprSVal(Expr* Ex) const;
+  SVal getBlkExprSVal(const Stmt* Ex) const;
   
-  SVal getSValAsScalarOrLoc(const Expr *Ex) const;
+  SVal getSValAsScalarOrLoc(const Stmt *Ex) const;
   
   SVal getSVal(Loc LV, QualType T = QualType()) const;
   
@@ -511,6 +511,7 @@
     return StoreMgr->getSelfRegion(state->getStore());
   }
   
+private:
   // Get the lvalue for a variable reference.
   SVal GetLValue(const GRState* St, const VarDecl* D) {
     return StoreMgr->getLValueVar(St, D);
@@ -540,9 +541,8 @@
     return StoreMgr->getLValueElement(St, ElementType, Base, Idx);
   }  
 
-  // Methods that query & manipulate the Environment.
-  
-  SVal GetSVal(const GRState* St, Stmt* Ex) {
+  // Methods that query & manipulate the Environment.  
+  SVal GetSVal(const GRState* St, const Stmt* Ex) {
     return St->getEnvironment().GetSVal(Ex, getBasicVals());
   }
   
@@ -555,17 +555,12 @@
     
     return UnknownVal();
   }
-    
 
-  SVal GetSVal(const GRState* St, const Stmt* Ex) {
-    return St->getEnvironment().GetSVal(const_cast<Stmt*>(Ex), getBasicVals());
-  }
-  
-  SVal GetBlkExprSVal(const GRState* St, Stmt* Ex) {
+  SVal GetBlkExprSVal(const GRState* St, const Stmt* Ex) {
     return St->getEnvironment().GetBlkExprSVal(Ex, getBasicVals());
   }
   
-  const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
+  const GRState* BindExpr(const GRState* St, const Stmt* Ex, SVal V,
                           bool isBlkExpr, bool Invalidate) {
     
     const Environment& OldEnv = St->getEnvironment();
@@ -579,7 +574,7 @@
     return getPersistentState(NewSt);
   }
   
-  const GRState* BindExpr(const GRState* St, Stmt* Ex, SVal V,
+  const GRState* BindExpr(const GRState* St, const Stmt* Ex, SVal V,
                           bool Invalidate = true) {
     
     bool isBlkExpr = false;
@@ -596,6 +591,8 @@
     return BindExpr(St, Ex, V, isBlkExpr, Invalidate);
   }
 
+public:
+
   SVal ArrayToPointer(Loc Array) {
     return StoreMgr->ArrayToPointer(Array);
   }
@@ -743,12 +740,12 @@
   return Mgr->ConstraintMgr->AssumeInBound(this, Idx, UpperBound, Assumption);
 }  
   
-inline const GRState *GRState::bindExpr(Stmt* Ex, SVal V, bool isBlkExpr,
-                                       bool Invalidate) const {
+inline const GRState *GRState::bindExpr(const Stmt* Ex, SVal V, bool isBlkExpr,
+                                        bool Invalidate) const {
   return Mgr->BindExpr(this, Ex, V, isBlkExpr, Invalidate);
 }
 
-inline const GRState *GRState::bindExpr(Stmt* Ex, SVal V,
+inline const GRState *GRState::bindExpr(const Stmt* Ex, SVal V,
                                         bool Invalidate) const {
   return Mgr->BindExpr(this, Ex, V, Invalidate);
 }
@@ -769,15 +766,15 @@
   return Mgr->getSymVal(this, sym);
 }
   
-inline SVal GRState::getSVal(Expr* Ex) const {
+inline SVal GRState::getSVal(const Stmt* Ex) const {
   return Mgr->GetSVal(this, Ex);
 }
 
-inline SVal GRState::getBlkExprSVal(Expr* Ex) const {  
+inline SVal GRState::getBlkExprSVal(const Stmt* Ex) const {  
   return Mgr->GetBlkExprSVal(this, Ex);
 }
 
-inline SVal GRState::getSValAsScalarOrLoc(const Expr *Ex) const {
+inline SVal GRState::getSValAsScalarOrLoc(const Stmt *Ex) const {
   return Mgr->GetSValAsScalarOrLoc(this, Ex);
 }
 

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Thu Jun 18 18:58:37 2009
@@ -181,7 +181,7 @@
 
   static NonLoc MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T);
   
-  static NonLoc MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I);
+  static NonLoc MakeVal(BasicValueFactory& BasicVals, const IntegerLiteral *I);
 
   static NonLoc MakeVal(BasicValueFactory& BasicVals, const llvm::APInt& I,
                         bool isUnsigned);
@@ -212,7 +212,7 @@
     
   static Loc MakeVal(const MemRegion* R);
     
-  static Loc MakeVal(AddrLabelExpr* E);
+  static Loc MakeVal(const AddrLabelExpr* E);
 
   static Loc MakeNull(BasicValueFactory &BasicVals);
   

Modified: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp Thu Jun 18 18:58:37 2009
@@ -66,9 +66,6 @@
   APIMisuse *BT;
   BugReporter& BR;
   ASTContext &Ctx;
-  GRStateManager* VMgr;
-
-  SVal GetSVal(const GRState* St, Expr* E) { return VMgr->GetSVal(St, E); }
       
   bool isNSString(ObjCInterfaceType* T, const char* suffix);
   bool AuditNSString(NodeTy* N, ObjCMessageExpr* ME);
@@ -79,9 +76,8 @@
   bool CheckNilArg(NodeTy* N, unsigned Arg);
 
 public:
-  BasicObjCFoundationChecks(ASTContext& ctx, GRStateManager* vmgr,
-                            BugReporter& br) 
-    : BT(0), BR(br), Ctx(ctx), VMgr(vmgr) {}
+  BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br) 
+    : BT(0), BR(br), Ctx(ctx) {}
         
   bool Audit(ExplodedNode<GRState>* N, GRStateManager&);
   
@@ -106,10 +102,8 @@
 
 
 GRSimpleAPICheck*
-clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx,
-                                       GRStateManager* VMgr, BugReporter& BR) {
-  
-  return new BasicObjCFoundationChecks(Ctx, VMgr, BR);  
+clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx, BugReporter& BR) {
+  return new BasicObjCFoundationChecks(Ctx, BR);  
 }
 
 
@@ -157,7 +151,7 @@
   
   Expr * E = ME->getArg(Arg);
   
-  if (isNil(GetSVal(N->getState(), E))) {
+  if (isNil(N->getState()->getSVal(E))) {
     WarnNilArg(N, ME, Arg);
     return true;
   }
@@ -259,14 +253,11 @@
   //   approach makes this class more stateless.
   ASTContext& Ctx;
   IdentifierInfo* II;
-  GRStateManager* VMgr;
   BugReporter& BR;
-    
-  SVal GetSVal(const GRState* St, Expr* E) { return VMgr->GetSVal(St, E); }
-  
+
 public:
-  AuditCFNumberCreate(ASTContext& ctx, GRStateManager* vmgr, BugReporter& br) 
-  : BT(0), Ctx(ctx), II(&Ctx.Idents.get("CFNumberCreate")), VMgr(vmgr), BR(br){}
+  AuditCFNumberCreate(ASTContext& ctx, BugReporter& br) 
+  : BT(0), Ctx(ctx), II(&Ctx.Idents.get("CFNumberCreate")), BR(br){}
   
   ~AuditCFNumberCreate() {}
   
@@ -374,14 +365,14 @@
 bool AuditCFNumberCreate::Audit(ExplodedNode<GRState>* N,GRStateManager&){  
   CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
   Expr* Callee = CE->getCallee();  
-  SVal CallV = GetSVal(N->getState(), Callee);  
+  SVal CallV = N->getState()->getSVal(Callee);  
   const FunctionDecl* FD = CallV.getAsFunctionDecl();
 
   if (!FD || FD->getIdentifier() != II || CE->getNumArgs()!=3)
     return false;
   
   // Get the value of the "theType" argument.
-  SVal  TheTypeVal = GetSVal(N->getState(), CE->getArg(1));
+  SVal TheTypeVal = N->getState()->getSVal(CE->getArg(1));
   
     // FIXME: We really should allow ranges of valid theType values, and
     //   bifurcate the state appropriately.
@@ -400,7 +391,7 @@
   // Look at the value of the integer being passed by reference.  Essentially
   // we want to catch cases where the value passed in is not equal to the
   // size of the type being created.
-  SVal TheValueExpr = GetSVal(N->getState(), CE->getArg(2));
+  SVal TheValueExpr = N->getState()->getSVal(CE->getArg(2));
   
   // FIXME: Eventually we should handle arbitrary locations.  We can do this
   //  by having an enhanced memory model that does low-level typing.
@@ -469,9 +460,8 @@
 }
 
 GRSimpleAPICheck*
-clang::CreateAuditCFNumberCreate(ASTContext& Ctx,
-                                 GRStateManager* VMgr, BugReporter& BR) {  
-  return new AuditCFNumberCreate(Ctx, VMgr, BR);
+clang::CreateAuditCFNumberCreate(ASTContext& Ctx, BugReporter& BR) {  
+  return new AuditCFNumberCreate(Ctx, BR);
 }
 
 //===----------------------------------------------------------------------===//
@@ -479,13 +469,12 @@
 
 void clang::RegisterAppleChecks(GRExprEngine& Eng) {
   ASTContext& Ctx = Eng.getContext();
-  GRStateManager* VMgr = &Eng.getStateManager();
   BugReporter &BR = Eng.getBugReporter();
 
-  Eng.AddCheck(CreateBasicObjCFoundationChecks(Ctx, VMgr, BR),
+  Eng.AddCheck(CreateBasicObjCFoundationChecks(Ctx, BR),
                Stmt::ObjCMessageExprClass);
 
-  Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, VMgr, BR),
+  Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, BR),
                Stmt::CallExprClass);
   
   RegisterNSErrorChecks(BR, Eng);

Modified: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h (original)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h Thu Jun 18 18:58:37 2009
@@ -33,11 +33,9 @@
 class GRExprEngine;
   
 GRSimpleAPICheck* CreateBasicObjCFoundationChecks(ASTContext& Ctx,
-                                                  GRStateManager* VMgr,
                                                   BugReporter& BR);
   
 GRSimpleAPICheck* CreateAuditCFNumberCreate(ASTContext& Ctx,
-                                            GRStateManager* VMgr,
                                             BugReporter& BR);
   
 void RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng);

Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Thu Jun 18 18:58:37 2009
@@ -336,7 +336,7 @@
     if (!DR)
       continue;
     
-    SVal Y = VMgr.GetSVal(N->getState(), DR);
+    SVal Y = N->getState()->getSVal(DR);
     
     if (X != Y)
       continue;

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Jun 18 18:58:37 2009
@@ -3056,7 +3056,7 @@
     // FIXME: Is this really working as expected?  There are cases where
     //  we just use the 'ID' from the message expression.
     const GRState* St = Builder.GetState(Pred);
-    SVal V = Eng.getStateManager().GetSValAsScalarOrLoc(St, Receiver);
+    SVal V = St->getSValAsScalarOrLoc(Receiver);
 
     SymbolRef Sym = V.getAsLocSymbol();
     if (Sym) {
@@ -3089,7 +3089,7 @@
     //  This is a hack.  When we have full-IP this should be removed.
     if (isa<ObjCMethodDecl>(&Eng.getGraph().getCodeDecl())) {      
       if (Expr* Receiver = ME->getReceiver()) {
-        SVal X = Eng.getStateManager().GetSValAsScalarOrLoc(St, Receiver);
+        SVal X = St->getSValAsScalarOrLoc(Receiver);
         if (loc::MemRegionVal* L = dyn_cast<loc::MemRegionVal>(&X))
           if (L->getRegion() == Eng.getStateManager().getSelfRegion(St)) {
             // Update the summary to make the default argument effect

Modified: cfe/trunk/lib/Analysis/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Environment.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/Environment.cpp (original)
+++ cfe/trunk/lib/Analysis/Environment.cpp Thu Jun 18 18:58:37 2009
@@ -18,7 +18,7 @@
 
 using namespace clang;
 
-SVal Environment::GetSVal(Stmt* E, BasicValueFactory& BasicVals) const {
+SVal Environment::GetSVal(const Stmt *E, BasicValueFactory& BasicVals) const {
   
   for (;;) {
     
@@ -34,7 +34,7 @@
         continue;
         
       case Stmt::CharacterLiteralClass: {
-        CharacterLiteral* C = cast<CharacterLiteral>(E);
+        const CharacterLiteral* C = cast<CharacterLiteral>(E);
         return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
       }
         
@@ -48,7 +48,7 @@
        
       case Stmt::ImplicitCastExprClass:
       case Stmt::CStyleCastExprClass: {
-        CastExpr* C = cast<CastExpr>(E);
+        const CastExpr* C = cast<CastExpr>(E);
         QualType CT = C->getType();
         
         if (CT->isVoidType())
@@ -69,7 +69,8 @@
   return LookupExpr(E);
 }
 
-SVal Environment::GetBlkExprSVal(Stmt* E, BasicValueFactory& BasicVals) const {
+SVal Environment::GetBlkExprSVal(const Stmt *E,
+                                 BasicValueFactory& BasicVals) const {
   
   while (1) {
     switch (E->getStmtClass()) {
@@ -78,7 +79,7 @@
         continue;
         
       case Stmt::CharacterLiteralClass: {
-        CharacterLiteral* C = cast<CharacterLiteral>(E);
+        const CharacterLiteral* C = cast<CharacterLiteral>(E);
         return NonLoc::MakeVal(BasicVals, C->getValue(), C->getType());
       }
         
@@ -92,8 +93,9 @@
   }
 }
 
-Environment EnvironmentManager::BindExpr(const Environment& Env, Stmt* E,SVal V,
-                                         bool isBlkExpr, bool Invalidate) {  
+Environment EnvironmentManager::BindExpr(const Environment& Env, const Stmt* E,
+                                         SVal V, bool isBlkExpr,
+                                         bool Invalidate) {  
   assert (E);
   
   if (V.isUnknown()) {    
@@ -136,7 +138,7 @@
   // Iterate over the block-expr bindings.
   for (Environment::beb_iterator I = Env.beb_begin(), E = Env.beb_end(); 
        I != E; ++I) {
-    Stmt* BlkExpr = I.getKey();
+    const Stmt *BlkExpr = I.getKey();
 
     if (SymReaper.isLive(Loc, BlkExpr)) {
       SVal X = I.getData();

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Jun 18 18:58:37 2009
@@ -644,7 +644,7 @@
   if (!bitsInit || !T->isIntegerType() || Ctx.getTypeSize(T) > bits)
     return UnknownVal();
   
-  return StateMgr.GetSVal(state, Ex);
+  return state->getSVal(Ex);
 }
 
 void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
@@ -1284,10 +1284,9 @@
   const void *OSAtomicStoreTag = &magic_store;
   
   // Load 'theValue'.
-  GRStateManager &StateMgr = Engine.getStateManager();
   const GRState *state = Pred->getState();
   ExplodedNodeSet<GRState> Tmp;
-  SVal location = StateMgr.GetSVal(state, theValueExpr);
+  SVal location = state->getSVal(theValueExpr);
   Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag);
 
   for (ExplodedNodeSet<GRState>::iterator I = Tmp.begin(), E = Tmp.end();
@@ -1310,8 +1309,7 @@
       // Perform the store.
       ExplodedNodeSet<GRState> TmpStore;
       Engine.EvalStore(TmpStore, theValueExpr, N, stateEqual, location, 
-                       StateMgr.GetSVal(stateEqual, newValueExpr),
-                       OSAtomicStoreTag);
+                       stateEqual->getSVal(newValueExpr), OSAtomicStoreTag);
       
       // Now bind the result of the comparison.
       for (ExplodedNodeSet<GRState>::iterator I2 = TmpStore.begin(),

Modified: cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp Thu Jun 18 18:58:37 2009
@@ -347,9 +347,7 @@
       assert (E && "Return expression cannot be NULL");
       
       // Get the value associated with E.
-      loc::MemRegionVal V =
-        cast<loc::MemRegionVal>(Eng.getStateManager().GetSVal(N->getState(),
-                                                               E));
+      loc::MemRegionVal V = cast<loc::MemRegionVal>(N->getState()->getSVal(E));
       
       // Generate a report for this bug.
       std::string buf;
@@ -427,7 +425,7 @@
       return Ex;
     }
     
-    bool MatchesCriteria(Expr* Ex) { return VM.GetSVal(St, Ex).isUndef(); }
+    bool MatchesCriteria(Expr* Ex) { return St->getSVal(Ex).isUndef(); }
   };
   
 public:
@@ -519,8 +517,7 @@
             "variable-length array (VLA) '"
          << VD->getNameAsString() << "' evaluates to ";
       
-      bool isUndefined = Eng.getStateManager().GetSVal(N->getState(),
-                                                       SizeExpr).isUndef();
+      bool isUndefined = N->getState()->getSVal(SizeExpr).isUndef();
       
       if (isUndefined)
         os << "an undefined or garbage value.";
@@ -563,7 +560,7 @@
     CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
     const GRState* state = N->getState();
     
-    SVal X = VMgr.GetSVal(state, CE->getCallee());
+    SVal X = state->getSVal(CE->getCallee());
 
     const FunctionDecl* FD = X.getAsFunctionDecl();
     if (!FD)
@@ -888,7 +885,7 @@
         StateMgr.getRegionManager().getVarRegion(VD);
 
       // What did we load?
-      SVal V = StateMgr.GetSVal(state, S);
+      SVal V = state->getSVal(S);
         
       if (isa<loc::ConcreteInt>(V) || isa<nonloc::ConcreteInt>(V) 
           || V.isUndef()) {
@@ -897,7 +894,7 @@
     }
   }
     
-  SVal V = StateMgr.GetSValAsScalarOrLoc(state, S);
+  SVal V = state->getSValAsScalarOrLoc(S);
   
   // Uncomment this to find cases where we aren't properly getting the
   // base value that was dereferenced.

Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Thu Jun 18 18:58:37 2009
@@ -363,7 +363,7 @@
   for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
         I != E; ++I) {
 
-    SVal V = StateMgr.GetSVal(St, *I);
+    SVal V = St->getSVal(*I);
     
     if (isa<loc::MemRegionVal>(V)) {
       const MemRegion *R = cast<loc::MemRegionVal>(V).getRegion();
@@ -382,7 +382,7 @@
   if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {    
     unsigned Count = Builder.getCurrentBlockCount();
     SVal X = Eng.getValueManager().getConjuredSymbolVal(CE, Count);
-    St = StateMgr.BindExpr(St, CE, X, Eng.getCFG().isBlkExpr(CE), false);
+    St = St->bindExpr(CE, X, Eng.getCFG().isBlkExpr(CE), false);
   }  
     
   Builder.MakeNode(Dst, CE, Pred, St);
@@ -400,18 +400,16 @@
   
   
   // The basic transfer function logic for message expressions does nothing.
-  // We just invalidate all arguments passed in by references.
-  
-  GRStateManager& StateMgr = Eng.getStateManager();
-  const GRState* St = Builder.GetState(Pred);
+  // We just invalidate all arguments passed in by references.  
+  const GRState *St = Builder.GetState(Pred);
   
   for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
        I != E; ++I) {
     
-    SVal V = StateMgr.GetSVal(St, *I);
+    SVal V = St->getSVal(*I);
     
     if (isa<Loc>(V))
-      St = StateMgr.BindLoc(St, cast<Loc>(V), UnknownVal());
+      St = St->bindLoc(cast<Loc>(V), UnknownVal());
   }
   
   Builder.MakeNode(Dst, ME, Pred, St);

Modified: cfe/trunk/lib/Analysis/GRTransferFuncs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRTransferFuncs.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRTransferFuncs.cpp (original)
+++ cfe/trunk/lib/Analysis/GRTransferFuncs.cpp Thu Jun 18 18:58:37 2009
@@ -23,6 +23,5 @@
                                   BinaryOperator::Opcode Op,
                                   NonLoc L, NonLoc R, QualType T) {
   
-  OStates.Add(Eng.getStateManager().BindExpr(St, Ex,
-                                          DetermEvalBinOpNN(Eng, Op, L, R, T)));
+  OStates.Add(St->bindExpr(Ex, DetermEvalBinOpNN(Eng, Op, L, R, T)));
 }

Modified: cfe/trunk/lib/Analysis/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=73740&r1=73739&r2=73740&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/SVals.cpp (original)
+++ cfe/trunk/lib/Analysis/SVals.cpp Thu Jun 18 18:58:37 2009
@@ -294,7 +294,7 @@
   return nonloc::ConcreteInt(BasicVals.getValue(X, T));
 }
 
-NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I) {
+NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, const IntegerLiteral* I) {
 
   return nonloc::ConcreteInt(BasicVals.getValue(APSInt(I->getValue(),
                               I->getType()->isUnsignedIntegerType())));
@@ -402,7 +402,9 @@
 
 Loc Loc::MakeVal(const MemRegion* R) { return loc::MemRegionVal(R); }
 
-Loc Loc::MakeVal(AddrLabelExpr* E) { return loc::GotoLabel(E->getLabel()); }
+Loc Loc::MakeVal(const AddrLabelExpr *E) {
+  return loc::GotoLabel(E->getLabel());
+}
 
 Loc Loc::MakeNull(BasicValueFactory &BasicVals) {
   return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth());





More information about the cfe-commits mailing list