[cfe-commits] r120605 - in /cfe/trunk: include/clang/Checker/PathSensitive/ lib/Checker/

Ted Kremenek kremenek at apple.com
Wed Dec 1 13:28:32 PST 2010


Author: kremenek
Date: Wed Dec  1 15:28:31 2010
New Revision: 120605

URL: http://llvm.org/viewvc/llvm-project?rev=120605&view=rev
Log:
Rename 'SValuator' to 'SValBuilder'.  The new name
reflects what the class actually does.

Added:
    cfe/trunk/include/clang/Checker/PathSensitive/SValBuilder.h
      - copied, changed from r120602, cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h
    cfe/trunk/lib/Checker/SValBuilder.cpp
      - copied, changed from r120602, cfe/trunk/lib/Checker/SValuator.cpp
    cfe/trunk/lib/Checker/SimpleSValBuilder.cpp
      - copied, changed from r120602, cfe/trunk/lib/Checker/SimpleSValuator.cpp
Removed:
    cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h
    cfe/trunk/lib/Checker/SValuator.cpp
    cfe/trunk/lib/Checker/SimpleSValuator.cpp
Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/Checker.h
    cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
    cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp
    cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp
    cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp
    cfe/trunk/lib/Checker/CMakeLists.txt
    cfe/trunk/lib/Checker/CStringChecker.cpp
    cfe/trunk/lib/Checker/CastSizeChecker.cpp
    cfe/trunk/lib/Checker/GRExprEngine.cpp
    cfe/trunk/lib/Checker/GRState.cpp
    cfe/trunk/lib/Checker/MallocChecker.cpp
    cfe/trunk/lib/Checker/OSAtomicChecker.cpp
    cfe/trunk/lib/Checker/RegionStore.cpp
    cfe/trunk/lib/Checker/SimpleConstraintManager.cpp
    cfe/trunk/lib/Checker/Store.cpp
    cfe/trunk/lib/Checker/UnixAPIChecker.cpp
    cfe/trunk/lib/Checker/VLASizeChecker.cpp
    cfe/trunk/lib/Checker/ValueManager.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Checker.h?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Checker.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Checker.h Wed Dec  1 15:28:31 2010
@@ -91,8 +91,8 @@
     return Eng.getValueManager();
   }
 
-  SValuator &getSValuator() {
-    return Eng.getSValuator();
+  SValBuilder &getSValBuilder() {
+    return Eng.getSValBuilder();
   }
 
   ExplodedNode *GenerateNode(bool autoTransition = true) {

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Wed Dec  1 15:28:31 2010
@@ -53,8 +53,8 @@
   /// ValMgr - Object that manages/creates SVals.
   ValueManager &ValMgr;
 
-  /// SVator - SValuator object that creates SVals from expressions.
-  SValuator &SVator;
+  /// svalBuilder - SValBuilder object that creates SVals from expressions.
+  SValBuilder &svalBuilder;
 
   /// EntryNode - The immediate predecessor node.
   ExplodedNode* EntryNode;
@@ -136,7 +136,7 @@
 
   virtual AnalysisManager &getAnalysisManager() { return AMgr; }
 
-  SValuator &getSValuator() { return SVator; }
+  SValBuilder &getSValBuilder() { return svalBuilder; }
 
   GRTransferFuncs& getTF() { return *TF; }
 
@@ -484,28 +484,28 @@
                          const Expr *Ex);
 
   SVal EvalMinus(SVal X) {
-    return X.isValid() ? SVator.EvalMinus(cast<NonLoc>(X)) : X;
+    return X.isValid() ? svalBuilder.EvalMinus(cast<NonLoc>(X)) : X;
   }
 
   SVal EvalComplement(SVal X) {
-    return X.isValid() ? SVator.EvalComplement(cast<NonLoc>(X)) : X;
+    return X.isValid() ? svalBuilder.EvalComplement(cast<NonLoc>(X)) : X;
   }
 
 public:
 
   SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode op,
                  NonLoc L, NonLoc R, QualType T) {
-    return SVator.EvalBinOpNN(state, op, L, R, T);
+    return svalBuilder.EvalBinOpNN(state, op, L, R, T);
   }
 
   SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode op,
                  NonLoc L, SVal R, QualType T) {
-    return R.isValid() ? SVator.EvalBinOpNN(state,op,L, cast<NonLoc>(R), T) : R;
+    return R.isValid() ? svalBuilder.EvalBinOpNN(state,op,L, cast<NonLoc>(R), T) : R;
   }
 
   SVal EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
                  SVal LHS, SVal RHS, QualType T) {
-    return SVator.EvalBinOp(ST, Op, LHS, RHS, T);
+    return svalBuilder.EvalBinOp(ST, Op, LHS, RHS, T);
   }
   
 protected:

Copied: cfe/trunk/include/clang/Checker/PathSensitive/SValBuilder.h (from r120602, cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/SValBuilder.h?p2=cfe/trunk/include/clang/Checker/PathSensitive/SValBuilder.h&p1=cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h&r1=120602&r2=120605&rev=120605&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/SValBuilder.h Wed Dec  1 15:28:31 2010
@@ -1,4 +1,4 @@
-// SValuator.h - Construction of SVals from evaluating expressions -*- C++ -*---
+// SValBuilder.h - Construction of SVals from evaluating expressions -*- C++ -*-
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,13 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines SValuator, a class that defines the interface for
+//  This file defines SValBuilder, a class that defines the interface for
 //  "symbolical evaluators" which construct an SVal from an expression.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_ANALYSIS_SVALUATOR
-#define LLVM_CLANG_ANALYSIS_SVALUATOR
+#ifndef LLVM_CLANG_ANALYSIS_SVALBUILDER
+#define LLVM_CLANG_ANALYSIS_SVALBUILDER
 
 #include "clang/AST/Expr.h"
 #include "clang/Checker/PathSensitive/SVals.h"
@@ -23,7 +23,7 @@
 class GRState;
 class ValueManager;
 
-class SValuator {
+class SValBuilder {
   friend class ValueManager;
 protected:
   ValueManager &ValMgr;
@@ -35,8 +35,8 @@
   virtual SVal EvalCastL(Loc val, QualType castTy) = 0;
 
 public:
-  SValuator(ValueManager &valMgr) : ValMgr(valMgr) {}
-  virtual ~SValuator() {}
+  SValBuilder(ValueManager &valMgr) : ValMgr(valMgr) {}
+  virtual ~SValBuilder() {}
 
   SVal EvalCast(SVal V, QualType castTy, QualType originalType);
   
@@ -64,7 +64,7 @@
                               DefinedOrUnknownSVal R);
 };
 
-SValuator* CreateSimpleSValuator(ValueManager &valMgr);
+SValBuilder* createSimpleSValBuilder(ValueManager &valMgr);
 
 } // end clang namespace
 #endif

Removed: cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h?rev=120604&view=auto
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/SValuator.h (removed)
@@ -1,70 +0,0 @@
-// SValuator.h - Construction of SVals from evaluating expressions -*- C++ -*---
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines SValuator, a class that defines the interface for
-//  "symbolical evaluators" which construct an SVal from an expression.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ANALYSIS_SVALUATOR
-#define LLVM_CLANG_ANALYSIS_SVALUATOR
-
-#include "clang/AST/Expr.h"
-#include "clang/Checker/PathSensitive/SVals.h"
-
-namespace clang {
-
-class GRState;
-class ValueManager;
-
-class SValuator {
-  friend class ValueManager;
-protected:
-  ValueManager &ValMgr;
-
-public:
-  // FIXME: Make these protected again one RegionStoreManager correctly
-  // handles loads from differening bound value types.
-  virtual SVal EvalCastNL(NonLoc val, QualType castTy) = 0;
-  virtual SVal EvalCastL(Loc val, QualType castTy) = 0;
-
-public:
-  SValuator(ValueManager &valMgr) : ValMgr(valMgr) {}
-  virtual ~SValuator() {}
-
-  SVal EvalCast(SVal V, QualType castTy, QualType originalType);
-  
-  virtual SVal EvalMinus(NonLoc val) = 0;
-
-  virtual SVal EvalComplement(NonLoc val) = 0;
-
-  virtual SVal EvalBinOpNN(const GRState *state, BinaryOperator::Opcode Op,
-                           NonLoc lhs, NonLoc rhs, QualType resultTy) = 0;
-
-  virtual SVal EvalBinOpLL(const GRState *state, BinaryOperator::Opcode Op,
-                           Loc lhs, Loc rhs, QualType resultTy) = 0;
-
-  virtual SVal EvalBinOpLN(const GRState *state, BinaryOperator::Opcode Op,
-                           Loc lhs, NonLoc rhs, QualType resultTy) = 0;
-
-  /// getKnownValue - Evaluates a given SVal. If the SVal has only one possible
-  ///  (integer) value, that value is returned. Otherwise, returns NULL.
-  virtual const llvm::APSInt *getKnownValue(const GRState *state, SVal V) = 0;
-  
-  SVal EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
-                 SVal L, SVal R, QualType T);
-  
-  DefinedOrUnknownSVal EvalEQ(const GRState *ST, DefinedOrUnknownSVal L,
-                              DefinedOrUnknownSVal R);
-};
-
-SValuator* CreateSimpleSValuator(ValueManager &valMgr);
-
-} // end clang namespace
-#endif

Modified: cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h Wed Dec  1 15:28:31 2010
@@ -21,7 +21,7 @@
 #include "clang/Checker/PathSensitive/SVals.h"
 #include "clang/Checker/PathSensitive/BasicValueFactory.h"
 #include "clang/Checker/PathSensitive/SymbolManager.h"
-#include "clang/Checker/PathSensitive/SValuator.h"
+#include "clang/Checker/PathSensitive/SValBuilder.h"
 #include "clang/AST/ExprCXX.h"
 
 namespace llvm { class BumpPtrAllocator; }
@@ -38,8 +38,8 @@
   /// SymMgr - Object that manages the symbol information.
   SymbolManager SymMgr;
 
-  /// SVator - SValuator object that creates SVals from expressions.
-  llvm::OwningPtr<SValuator> SVator;
+  /// svalBuilder - SValBuilder object that creates SVals from expressions.
+  llvm::OwningPtr<SValBuilder> svalBuilder;
 
   MemRegionManager MemMgr;
 
@@ -57,7 +57,7 @@
                  ArrayIndexTy(context.IntTy),
                  ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {
     // FIXME: Generalize later.
-    SVator.reset(clang::CreateSimpleSValuator(*this));
+    svalBuilder.reset(clang::createSimpleSValBuilder(*this));
   }
 
   // Accessors to submanagers.
@@ -73,7 +73,7 @@
   SymbolManager &getSymbolManager() { return SymMgr; }
   const SymbolManager &getSymbolManager() const { return SymMgr; }
 
-  SValuator &getSValuator() { return *SVator.get(); }
+  SValBuilder &getSValBuilder() { return *svalBuilder.get(); }
 
   MemRegionManager &getRegionManager() { return MemMgr; }
   const MemRegionManager &getRegionManager() const { return MemMgr; }

Modified: cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp (original)
+++ cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp Wed Dec  1 15:28:31 2010
@@ -88,8 +88,8 @@
   if (expectedResultTy != actualResultTy) {
     // FIXME: Do more checking and actual emit an error. At least performing
     // the cast avoids some assertion failures elsewhere.
-    SValuator &SVator = C.getSValuator();
-    V = SVator.EvalCast(V, expectedResultTy, actualResultTy);
+    SValBuilder &svalBuilder = C.getSValBuilder();
+    V = svalBuilder.EvalCast(V, expectedResultTy, actualResultTy);
     C.GenerateNode(state->BindExpr(CE, V));
   }
 }

Modified: cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp Wed Dec  1 15:28:31 2010
@@ -413,8 +413,8 @@
   DefinedSVal Zero = cast<DefinedSVal>(ValMgr.makeZeroVal(Arg->getType()));
 
   // Make an expression asserting that they're equal.
-  SValuator &SVator = ValMgr.getSValuator();
-  DefinedOrUnknownSVal ArgIsNull = SVator.EvalEQ(state, Zero, *DefArgVal);
+  SValBuilder &svalBuilder = ValMgr.getSValBuilder();
+  DefinedOrUnknownSVal ArgIsNull = svalBuilder.EvalEQ(state, Zero, *DefArgVal);
 
   // Are they equal?
   const GRState *stateTrue, *stateFalse;

Modified: cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp (original)
+++ cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp Wed Dec  1 15:28:31 2010
@@ -70,9 +70,9 @@
     ValueManager& ValMgr = C.getValueManager();
     DefinedOrUnknownSVal Extent = R->getExtent(ValMgr);
 
-    SValuator& SVator = ValMgr.getSValuator();
+    SValBuilder& svalBuilder = ValMgr.getSValBuilder();
     DefinedOrUnknownSVal ExtentMatchesSizeArg =
-      SVator.EvalEQ(state, Extent, Size);
+      svalBuilder.EvalEQ(state, Extent, Size);
     state = state->Assume(ExtentMatchesSizeArg, true);
 
     C.GenerateNode(state->BindExpr(CE, loc::MemRegionVal(R)));

Modified: cfe/trunk/lib/Checker/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CMakeLists.txt?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CMakeLists.txt (original)
+++ cfe/trunk/lib/Checker/CMakeLists.txt Wed Dec  1 15:28:31 2010
@@ -66,10 +66,10 @@
   RegionStore.cpp
   ReturnPointerRangeChecker.cpp
   ReturnUndefChecker.cpp
+  SValBuilder.cpp
   SVals.cpp
-  SValuator.cpp
   SimpleConstraintManager.cpp
-  SimpleSValuator.cpp
+  SimpleSValBuilder.cpp
   StackAddrLeakChecker.cpp
   Store.cpp
   StreamChecker.cpp

Modified: cfe/trunk/lib/Checker/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CStringChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CStringChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CStringChecker.cpp Wed Dec  1 15:28:31 2010
@@ -122,7 +122,7 @@
     return std::pair<const GRState*, const GRState *>(state, state);
 
   ValueManager &ValMgr = C.getValueManager();
-  SValuator &SV = ValMgr.getSValuator();
+  SValBuilder &SV = ValMgr.getSValBuilder();
 
   DefinedOrUnknownSVal Zero = ValMgr.makeZeroVal(Ty);
   DefinedOrUnknownSVal ValIsZero = SV.EvalEQ(state, *Val, Zero);
@@ -245,7 +245,7 @@
     return NULL;
 
   ValueManager &VM = C.getValueManager();
-  SValuator &SV = VM.getSValuator();
+  SValBuilder &SV = VM.getSValBuilder();
   ASTContext &Ctx = C.getASTContext();
 
   QualType SizeTy = Size->getType();
@@ -313,7 +313,7 @@
     return NULL;
 
   ValueManager &VM = state->getStateManager().getValueManager();
-  SValuator &SV = VM.getSValuator();
+  SValBuilder &SV = VM.getSValBuilder();
   ASTContext &Ctx = VM.getContext();
   const GRState *stateTrue, *stateFalse;
 
@@ -716,7 +716,7 @@
 
   const GRState *state = C.getState();
   ValueManager &ValMgr = C.getValueManager();
-  SValuator &SV = ValMgr.getSValuator();
+  SValBuilder &SV = ValMgr.getSValBuilder();
 
   // See if the size argument is zero.
   SVal SizeVal = state->getSVal(Size);
@@ -850,7 +850,7 @@
   if (loc::MemRegionVal *DstRegVal = dyn_cast<loc::MemRegionVal>(&DstVal)) {
     // If the length is known, we can check for an overflow.
     if (NonLoc *KnownStrLen = dyn_cast<NonLoc>(&StrLen)) {
-      SValuator &SV = C.getSValuator();
+      SValBuilder &SV = C.getSValBuilder();
 
       SVal LastElement = SV.EvalBinOpLN(state, BO_Add,
                                         *DstRegVal, *KnownStrLen,

Modified: cfe/trunk/lib/Checker/CastSizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CastSizeChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CastSizeChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CastSizeChecker.cpp Wed Dec  1 15:28:31 2010
@@ -60,8 +60,8 @@
   ValueManager &ValMgr = C.getValueManager();
   SVal Extent = SR->getExtent(ValMgr);
 
-  SValuator &SVator = ValMgr.getSValuator();
-  const llvm::APSInt *ExtentInt = SVator.getKnownValue(state, Extent);
+  SValBuilder &svalBuilder = ValMgr.getSValBuilder();
+  const llvm::APSInt *ExtentInt = svalBuilder.getKnownValue(state, Extent);
   if (!ExtentInt)
     return;
 

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed Dec  1 15:28:31 2010
@@ -326,7 +326,7 @@
              *this),
     SymMgr(StateMgr.getSymbolManager()),
     ValMgr(StateMgr.getValueManager()),
-    SVator(ValMgr.getSValuator()),
+    svalBuilder(ValMgr.getSValBuilder()),
     EntryNode(NULL), CurrentStmt(NULL),
     NSExceptionII(NULL), NSExceptionInstanceRaiseSelectors(NULL),
     RaiseSel(GetNullarySelector("raise", getContext())),
@@ -1597,7 +1597,7 @@
 
     do {
       nonloc::ConcreteInt CaseVal(getBasicVals().getValue(V1.Val.getInt()));
-      DefinedOrUnknownSVal Res = SVator.EvalEQ(DefaultSt ? DefaultSt : state,
+      DefinedOrUnknownSVal Res = svalBuilder.EvalEQ(DefaultSt ? DefaultSt : state,
                                                CondV, CaseVal);
 
       // Now "assume" that the case matches.
@@ -2691,12 +2691,12 @@
   case CK_AnyPointerToBlockPointerCast:
   
   case CK_ObjCObjectLValueCast: {
-    // Delegate to SValuator to process.
+    // Delegate to SValBuilder to process.
     for (ExplodedNodeSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) {
       ExplodedNode* N = *I;
       const GRState* state = GetState(N);
       SVal V = state->getSVal(Ex);
-      V = SVator.EvalCast(V, T, ExTy);
+      V = svalBuilder.EvalCast(V, T, ExTy);
       state = state->BindExpr(CastE, V);
       MakeNode(Dst, CastE, N, state);
     }
@@ -3268,12 +3268,12 @@
         // propagate that constraint.
         if (Loc::IsLocType(U->getType())) {
           DefinedOrUnknownSVal Constraint =
-            SVator.EvalEQ(state, V2, ValMgr.makeZeroVal(U->getType()));
+            svalBuilder.EvalEQ(state, V2, ValMgr.makeZeroVal(U->getType()));
 
           if (!state->Assume(Constraint, true)) {
             // It isn't feasible for the original value to be null.
             // Propagate this constraint.
-            Constraint = SVator.EvalEQ(state, SymVal,
+            Constraint = svalBuilder.EvalEQ(state, SymVal,
                                        ValMgr.makeZeroVal(U->getType()));
 
 
@@ -3516,10 +3516,10 @@
         QualType RTy = getContext().getCanonicalType(RHS->getType());
 
         // Promote LHS.
-        V = SVator.EvalCast(V, CLHSTy, LTy);
+        V = svalBuilder.EvalCast(V, CLHSTy, LTy);
 
         // Compute the result of the operation.
-        SVal Result = SVator.EvalCast(EvalBinOp(state, Op, V, RightV, CTy),
+        SVal Result = svalBuilder.EvalCast(EvalBinOp(state, Op, V, RightV, CTy),
                                       B->getType(), CTy);
 
         // EXPERIMENTAL: "Conjured" symbols.
@@ -3538,12 +3538,12 @@
           LHSVal = ValMgr.getConjuredSymbolVal(NULL, B->getRHS(), LTy, Count);
 
           // However, we need to convert the symbol to the computation type.
-          Result = SVator.EvalCast(LHSVal, CTy, LTy);
+          Result = svalBuilder.EvalCast(LHSVal, CTy, LTy);
         }
         else {
           // The left-hand side may bind to a different value then the
           // computation type.
-          LHSVal = SVator.EvalCast(Result, LTy, CTy);
+          LHSVal = svalBuilder.EvalCast(Result, LTy, CTy);
         }
 
         EvalStore(Tmp3, B, LHS, *I4, state->BindExpr(B, Result),

Modified: cfe/trunk/lib/Checker/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRState.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRState.cpp (original)
+++ cfe/trunk/lib/Checker/GRState.cpp Wed Dec  1 15:28:31 2010
@@ -238,10 +238,10 @@
 
   // Build an expression for 0 <= Idx < UpperBound.
   // This is the same as Idx + MIN < UpperBound + MIN, if overflow is allowed.
-  // FIXME: This should probably be part of SValuator.
+  // FIXME: This should probably be part of SValBuilder.
   GRStateManager &SM = getStateManager();
   ValueManager &VM = SM.getValueManager();
-  SValuator &SV = VM.getSValuator();
+  SValBuilder &SV = VM.getSValBuilder();
   ASTContext &Ctx = VM.getContext();
 
   // Get the offset: the minimum value of the array index type.

Modified: cfe/trunk/lib/Checker/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MallocChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MallocChecker.cpp (original)
+++ cfe/trunk/lib/Checker/MallocChecker.cpp Wed Dec  1 15:28:31 2010
@@ -241,9 +241,9 @@
   DefinedOrUnknownSVal Extent = R->getExtent(ValMgr);
   DefinedOrUnknownSVal DefinedSize = cast<DefinedOrUnknownSVal>(Size);
 
-  SValuator &SVator = ValMgr.getSValuator();
+  SValBuilder &svalBuilder = ValMgr.getSValBuilder();
   DefinedOrUnknownSVal ExtentMatchesSize =
-    SVator.EvalEQ(state, Extent, DefinedSize);
+    svalBuilder.EvalEQ(state, Extent, DefinedSize);
   state = state->Assume(ExtentMatchesSize, true);
 
   SymbolRef Sym = RetVal.getAsLocSymbol();
@@ -504,9 +504,9 @@
   DefinedOrUnknownSVal Arg0Val=cast<DefinedOrUnknownSVal>(state->getSVal(Arg0));
 
   ValueManager &ValMgr = C.getValueManager();
-  SValuator &SVator = C.getSValuator();
+  SValBuilder &svalBuilder = C.getSValBuilder();
 
-  DefinedOrUnknownSVal PtrEQ = SVator.EvalEQ(state, Arg0Val, ValMgr.makeNull());
+  DefinedOrUnknownSVal PtrEQ = svalBuilder.EvalEQ(state, Arg0Val, ValMgr.makeNull());
 
   // If the ptr is NULL, the call is equivalent to malloc(size).
   if (const GRState *stateEqual = state->Assume(PtrEQ, true)) {
@@ -527,7 +527,7 @@
     const Expr *Arg1 = CE->getArg(1);
     DefinedOrUnknownSVal Arg1Val = 
       cast<DefinedOrUnknownSVal>(stateNotEqual->getSVal(Arg1));
-    DefinedOrUnknownSVal SizeZero = SVator.EvalEQ(stateNotEqual, Arg1Val,
+    DefinedOrUnknownSVal SizeZero = svalBuilder.EvalEQ(stateNotEqual, Arg1Val,
                                       ValMgr.makeIntValWithPtrWidth(0, false));
 
     if (const GRState *stateSizeZero = stateNotEqual->Assume(SizeZero, true)) {
@@ -552,11 +552,11 @@
   const GRState *state = C.getState();
   
   ValueManager &ValMgr = C.getValueManager();
-  SValuator &SVator = C.getSValuator();
+  SValBuilder &svalBuilder = C.getSValBuilder();
 
   SVal Count = state->getSVal(CE->getArg(0));
   SVal EleSize = state->getSVal(CE->getArg(1));
-  SVal TotalSize = SVator.EvalBinOp(state, BO_Mul, Count, EleSize,
+  SVal TotalSize = svalBuilder.EvalBinOp(state, BO_Mul, Count, EleSize,
                                     ValMgr.getContext().getSizeType());
   
   SVal Zero = ValMgr.makeZeroVal(ValMgr.getContext().CharTy);

Modified: cfe/trunk/lib/Checker/OSAtomicChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/OSAtomicChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/OSAtomicChecker.cpp (original)
+++ cfe/trunk/lib/Checker/OSAtomicChecker.cpp Wed Dec  1 15:28:31 2010
@@ -142,10 +142,10 @@
     DefinedOrUnknownSVal oldValueVal =
       cast<DefinedOrUnknownSVal>(oldValueVal_untested);
 
-    SValuator &SVator = Engine.getSValuator();
+    SValBuilder &svalBuilder = Engine.getSValBuilder();
 
     // Perform the comparison.
-    DefinedOrUnknownSVal Cmp = SVator.EvalEQ(stateLoad,theValueVal,oldValueVal);
+    DefinedOrUnknownSVal Cmp = svalBuilder.EvalEQ(stateLoad,theValueVal,oldValueVal);
 
     const GRState *stateEqual = stateLoad->Assume(Cmp, true);
 
@@ -158,7 +158,7 @@
       // Handle implicit value casts.
       if (const TypedRegion *R =
           dyn_cast_or_null<TypedRegion>(location.getAsRegion())) {
-        val = SVator.EvalCast(val,R->getValueType(), newValueExpr->getType());
+        val = svalBuilder.EvalCast(val,R->getValueType(), newValueExpr->getType());
       }
 
       Engine.EvalStore(TmpStore, NULL, theValueExpr, N, 

Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Wed Dec  1 15:28:31 2010
@@ -756,8 +756,8 @@
                                                            const MemRegion *R,
                                                            QualType EleTy) {
   SVal Size = cast<SubRegion>(R)->getExtent(ValMgr);
-  SValuator &SVator = ValMgr.getSValuator();
-  const llvm::APSInt *SizeInt = SVator.getKnownValue(state, Size);
+  SValBuilder &svalBuilder = ValMgr.getSValBuilder();
+  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
   if (!SizeInt)
     return UnknownVal();
 
@@ -911,7 +911,7 @@
   //  (b) 0 + symbolic index
   if (Base) {
     if (nonloc::ConcreteInt *Offset = dyn_cast<nonloc::ConcreteInt>(&R)) {
-      // FIXME: Should use SValuator here.
+      // FIXME: Should use SValBuilder here.
       SVal NewIdx =
         Base->evalBinOp(ValMgr, Op,
                 cast<nonloc::ConcreteInt>(ValMgr.convertToArrayIndex(*Offset)));
@@ -1307,8 +1307,8 @@
           if (const IntegerLiteral *IL =
               dyn_cast<IntegerLiteral>(Init->IgnoreParenCasts())) {
             const nonloc::ConcreteInt &V = ValMgr.makeIntVal(IL);
-            return ValMgr.getSValuator().EvalCast(V, Init->getType(),
-                                                  IL->getType());
+            return ValMgr.getSValBuilder().EvalCast(V, Init->getType(),
+                                                    IL->getType());
           }
       }
 

Copied: cfe/trunk/lib/Checker/SValBuilder.cpp (from r120602, cfe/trunk/lib/Checker/SValuator.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SValBuilder.cpp?p2=cfe/trunk/lib/Checker/SValBuilder.cpp&p1=cfe/trunk/lib/Checker/SValuator.cpp&r1=120602&r2=120605&rev=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SValuator.cpp (original)
+++ cfe/trunk/lib/Checker/SValBuilder.cpp Wed Dec  1 15:28:31 2010
@@ -1,4 +1,4 @@
-// SValuator.cpp - Basic class for all SValuator implementations --*- C++ -*--//
+// SValBuilder.cpp - Basic class for all SValBuilder implementations -*- C++ -*-
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,18 +7,18 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines SValuator, the base class for all (complete) SValuator
+//  This file defines SValBuilder, the base class for all (complete) SValBuilder
 //  implementations.
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Checker/PathSensitive/SValuator.h"
+#include "clang/Checker/PathSensitive/SValBuilder.h"
 #include "clang/Checker/PathSensitive/GRState.h"
 
 using namespace clang;
 
 
-SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
+SVal SValBuilder::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
                           SVal L, SVal R, QualType T) {
 
   if (L.isUndef() || R.isUndef())
@@ -46,7 +46,7 @@
   return EvalBinOpNN(ST, Op, cast<NonLoc>(L), cast<NonLoc>(R), T);
 }
 
-DefinedOrUnknownSVal SValuator::EvalEQ(const GRState *ST,
+DefinedOrUnknownSVal SValBuilder::EvalEQ(const GRState *ST,
                                        DefinedOrUnknownSVal L,
                                        DefinedOrUnknownSVal R) {
   return cast<DefinedOrUnknownSVal>(EvalBinOp(ST, BO_EQ, L, R,
@@ -54,7 +54,7 @@
 }
 
 // FIXME: should rewrite according to the cast kind.
-SVal SValuator::EvalCast(SVal val, QualType castTy, QualType originalTy) {
+SVal SValBuilder::EvalCast(SVal val, QualType castTy, QualType originalTy) {
   if (val.isUnknownOrUndef() || castTy == originalTy)
     return val;
 

Removed: cfe/trunk/lib/Checker/SValuator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SValuator.cpp?rev=120604&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/SValuator.cpp (original)
+++ cfe/trunk/lib/Checker/SValuator.cpp (removed)
@@ -1,169 +0,0 @@
-// SValuator.cpp - Basic class for all SValuator implementations --*- C++ -*--//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines SValuator, the base class for all (complete) SValuator
-//  implementations.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Checker/PathSensitive/SValuator.h"
-#include "clang/Checker/PathSensitive/GRState.h"
-
-using namespace clang;
-
-
-SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
-                          SVal L, SVal R, QualType T) {
-
-  if (L.isUndef() || R.isUndef())
-    return UndefinedVal();
-
-  if (L.isUnknown() || R.isUnknown())
-    return UnknownVal();
-
-  if (isa<Loc>(L)) {
-    if (isa<Loc>(R))
-      return EvalBinOpLL(ST, Op, cast<Loc>(L), cast<Loc>(R), T);
-
-    return EvalBinOpLN(ST, Op, cast<Loc>(L), cast<NonLoc>(R), T);
-  }
-
-  if (isa<Loc>(R)) {
-    // Support pointer arithmetic where the addend is on the left
-    // and the pointer on the right.
-    assert(Op == BO_Add);
-
-    // Commute the operands.
-    return EvalBinOpLN(ST, Op, cast<Loc>(R), cast<NonLoc>(L), T);
-  }
-
-  return EvalBinOpNN(ST, Op, cast<NonLoc>(L), cast<NonLoc>(R), T);
-}
-
-DefinedOrUnknownSVal SValuator::EvalEQ(const GRState *ST,
-                                       DefinedOrUnknownSVal L,
-                                       DefinedOrUnknownSVal R) {
-  return cast<DefinedOrUnknownSVal>(EvalBinOp(ST, BO_EQ, L, R,
-                                              ValMgr.getContext().IntTy));
-}
-
-// FIXME: should rewrite according to the cast kind.
-SVal SValuator::EvalCast(SVal val, QualType castTy, QualType originalTy) {
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-    return val;
-
-  ASTContext &C = ValMgr.getContext();
-
-  // For const casts, just propagate the value.
-  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
-    if (C.hasSameUnqualifiedType(castTy, originalTy))
-      return val;
-
-  // Check for casts to real or complex numbers.  We don't handle these at all
-  // right now.
-  if (castTy->isFloatingType() || castTy->isAnyComplexType())
-    return UnknownVal();
-  
-  // Check for casts from integers to integers.
-  if (castTy->isIntegerType() && originalTy->isIntegerType())
-    return EvalCastNL(cast<NonLoc>(val), castTy);
-
-  // Check for casts from pointers to integers.
-  if (castTy->isIntegerType() && Loc::IsLocType(originalTy))
-    return EvalCastL(cast<Loc>(val), castTy);
-
-  // Check for casts from integers to pointers.
-  if (Loc::IsLocType(castTy) && originalTy->isIntegerType()) {
-    if (nonloc::LocAsInteger *LV = dyn_cast<nonloc::LocAsInteger>(&val)) {
-      if (const MemRegion *R = LV->getLoc().getAsRegion()) {
-        StoreManager &storeMgr = ValMgr.getStateManager().getStoreManager();
-        R = storeMgr.CastRegion(R, castTy);
-        return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-      }
-      return LV->getLoc();
-    }
-    goto DispatchCast;
-  }
-
-  // Just pass through function and block pointers.
-  if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) {
-    assert(Loc::IsLocType(castTy));
-    return val;
-  }
-
-  // Check for casts from array type to another type.
-  if (originalTy->isArrayType()) {
-    // We will always decay to a pointer.
-    val = ValMgr.getStateManager().ArrayToPointer(cast<Loc>(val));
-
-    // Are we casting from an array to a pointer?  If so just pass on
-    // the decayed value.
-    if (castTy->isPointerType())
-      return val;
-
-    // Are we casting from an array to an integer?  If so, cast the decayed
-    // pointer value to an integer.
-    assert(castTy->isIntegerType());
-
-    // FIXME: Keep these here for now in case we decide soon that we
-    // need the original decayed type.
-    //    QualType elemTy = cast<ArrayType>(originalTy)->getElementType();
-    //    QualType pointerTy = C.getPointerType(elemTy);
-    return EvalCastL(cast<Loc>(val), castTy);
-  }
-
-  // Check for casts from a region to a specific type.
-  if (const MemRegion *R = val.getAsRegion()) {
-    // FIXME: We should handle the case where we strip off view layers to get
-    //  to a desugared type.
-
-    if (!Loc::IsLocType(castTy)) {
-      // FIXME: There can be gross cases where one casts the result of a function
-      // (that returns a pointer) to some other value that happens to fit
-      // within that pointer value.  We currently have no good way to
-      // model such operations.  When this happens, the underlying operation
-      // is that the caller is reasoning about bits.  Conceptually we are
-      // layering a "view" of a location on top of those bits.  Perhaps
-      // we need to be more lazy about mutual possible views, even on an
-      // SVal?  This may be necessary for bit-level reasoning as well.
-      return UnknownVal();
-    }
-
-    // We get a symbolic function pointer for a dereference of a function
-    // pointer, but it is of function type. Example:
-
-    //  struct FPRec {
-    //    void (*my_func)(int * x);
-    //  };
-    //
-    //  int bar(int x);
-    //
-    //  int f1_a(struct FPRec* foo) {
-    //    int x;
-    //    (*foo->my_func)(&x);
-    //    return bar(x)+1; // no-warning
-    //  }
-
-    assert(Loc::IsLocType(originalTy) || originalTy->isFunctionType() ||
-           originalTy->isBlockPointerType());
-
-    StoreManager &storeMgr = ValMgr.getStateManager().getStoreManager();
-
-    // Delegate to store manager to get the result of casting a region to a
-    // different type.  If the MemRegion* returned is NULL, this expression
-    // evaluates to UnknownVal.
-    R = storeMgr.CastRegion(R, castTy);
-    return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-  }
-
-DispatchCast:
-  // All other cases.
-  return isa<Loc>(val) ? EvalCastL(cast<Loc>(val), castTy)
-                       : EvalCastNL(cast<NonLoc>(val), castTy);
-}

Modified: cfe/trunk/lib/Checker/SimpleConstraintManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SimpleConstraintManager.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SimpleConstraintManager.cpp (original)
+++ cfe/trunk/lib/Checker/SimpleConstraintManager.cpp Wed Dec  1 15:28:31 2010
@@ -121,7 +121,7 @@
 
 static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
   // FIXME: This should probably be part of BinaryOperator, since this isn't
-  // the only place it's used. (This code was copied from SimpleSValuator.cpp.)
+  // the only place it's used. (This code was copied from SimpleSValBuilder.cpp.)
   switch (op) {
   default:
     assert(false && "Invalid opcode.");

Copied: cfe/trunk/lib/Checker/SimpleSValBuilder.cpp (from r120602, cfe/trunk/lib/Checker/SimpleSValuator.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SimpleSValBuilder.cpp?p2=cfe/trunk/lib/Checker/SimpleSValBuilder.cpp&p1=cfe/trunk/lib/Checker/SimpleSValuator.cpp&r1=120602&r2=120605&rev=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SimpleSValuator.cpp (original)
+++ cfe/trunk/lib/Checker/SimpleSValBuilder.cpp Wed Dec  1 15:28:31 2010
@@ -1,4 +1,4 @@
-// SimpleSValuator.cpp - A basic SValuator ------------------------*- C++ -*--//
+// SimpleSValBuilder.cpp - A basic SValBuilder -----------------------*- C++ -*-
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,24 +7,24 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines SimpleSValuator, a basic implementation of SValuator.
+//  This file defines SimpleSValBuilder, a basic implementation of SValBuilder.
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Checker/PathSensitive/SValuator.h"
+#include "clang/Checker/PathSensitive/SValBuilder.h"
 #include "clang/Checker/PathSensitive/GRState.h"
 
 using namespace clang;
 
 namespace {
-class SimpleSValuator : public SValuator {
+class SimpleSValBuilder : public SValBuilder {
 protected:
   virtual SVal EvalCastNL(NonLoc val, QualType castTy);
   virtual SVal EvalCastL(Loc val, QualType castTy);
 
 public:
-  SimpleSValuator(ValueManager &valMgr) : SValuator(valMgr) {}
-  virtual ~SimpleSValuator() {}
+  SimpleSValBuilder(ValueManager &valMgr) : SValBuilder(valMgr) {}
+  virtual ~SimpleSValBuilder() {}
 
   virtual SVal EvalMinus(NonLoc val);
   virtual SVal EvalComplement(NonLoc val);
@@ -44,15 +44,15 @@
 };
 } // end anonymous namespace
 
-SValuator *clang::CreateSimpleSValuator(ValueManager &valMgr) {
-  return new SimpleSValuator(valMgr);
+SValBuilder *clang::createSimpleSValBuilder(ValueManager &valMgr) {
+  return new SimpleSValBuilder(valMgr);
 }
 
 //===----------------------------------------------------------------------===//
 // Transfer function for Casts.
 //===----------------------------------------------------------------------===//
 
-SVal SimpleSValuator::EvalCastNL(NonLoc val, QualType castTy) {
+SVal SimpleSValBuilder::EvalCastNL(NonLoc val, QualType castTy) {
 
   bool isLocType = Loc::IsLocType(castTy);
 
@@ -104,7 +104,7 @@
     return ValMgr.makeIntVal(i);
 }
 
-SVal SimpleSValuator::EvalCastL(Loc val, QualType castTy) {
+SVal SimpleSValBuilder::EvalCastL(Loc val, QualType castTy) {
 
   // Casts from pointers -> pointers, just return the lval.
   //
@@ -142,7 +142,7 @@
 // Transfer function for unary operators.
 //===----------------------------------------------------------------------===//
 
-SVal SimpleSValuator::EvalMinus(NonLoc val) {
+SVal SimpleSValBuilder::EvalMinus(NonLoc val) {
   switch (val.getSubKind()) {
   case nonloc::ConcreteIntKind:
     return cast<nonloc::ConcreteInt>(val).evalMinus(ValMgr);
@@ -151,7 +151,7 @@
   }
 }
 
-SVal SimpleSValuator::EvalComplement(NonLoc X) {
+SVal SimpleSValBuilder::EvalComplement(NonLoc X) {
   switch (X.getSubKind()) {
   case nonloc::ConcreteIntKind:
     return cast<nonloc::ConcreteInt>(X).evalComplement(ValMgr);
@@ -191,7 +191,7 @@
   }
 }
 
-SVal SimpleSValuator::MakeSymIntVal(const SymExpr *LHS,
+SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS,
                                     BinaryOperator::Opcode op,
                                     const llvm::APSInt &RHS,
                                     QualType resultTy) {
@@ -266,7 +266,7 @@
   return ValMgr.makeNonLoc(LHS, op, RHS, resultTy);
 }
 
-SVal SimpleSValuator::EvalBinOpNN(const GRState *state,
+SVal SimpleSValBuilder::EvalBinOpNN(const GRState *state,
                                   BinaryOperator::Opcode op,
                                   NonLoc lhs, NonLoc rhs,
                                   QualType resultTy)  {
@@ -515,7 +515,7 @@
 }
 
 // FIXME: all this logic will change if/when we have MemRegion::getLocation().
-SVal SimpleSValuator::EvalBinOpLL(const GRState *state,
+SVal SimpleSValBuilder::EvalBinOpLL(const GRState *state,
                                   BinaryOperator::Opcode op,
                                   Loc lhs, Loc rhs,
                                   QualType resultTy) {
@@ -812,7 +812,7 @@
   }
 }
 
-SVal SimpleSValuator::EvalBinOpLN(const GRState *state,
+SVal SimpleSValBuilder::EvalBinOpLN(const GRState *state,
                                   BinaryOperator::Opcode op,
                                   Loc lhs, NonLoc rhs, QualType resultTy) {
   // Special case: 'rhs' is an integer that has the same width as a pointer and
@@ -872,7 +872,7 @@
                                                               rhs, resultTy);
 }
 
-const llvm::APSInt *SimpleSValuator::getKnownValue(const GRState *state,
+const llvm::APSInt *SimpleSValBuilder::getKnownValue(const GRState *state,
                                                    SVal V) {
   if (V.isUnknownOrUndef())
     return NULL;

Removed: cfe/trunk/lib/Checker/SimpleSValuator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SimpleSValuator.cpp?rev=120604&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/SimpleSValuator.cpp (original)
+++ cfe/trunk/lib/Checker/SimpleSValuator.cpp (removed)
@@ -1,891 +0,0 @@
-// SimpleSValuator.cpp - A basic SValuator ------------------------*- C++ -*--//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines SimpleSValuator, a basic implementation of SValuator.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Checker/PathSensitive/SValuator.h"
-#include "clang/Checker/PathSensitive/GRState.h"
-
-using namespace clang;
-
-namespace {
-class SimpleSValuator : public SValuator {
-protected:
-  virtual SVal EvalCastNL(NonLoc val, QualType castTy);
-  virtual SVal EvalCastL(Loc val, QualType castTy);
-
-public:
-  SimpleSValuator(ValueManager &valMgr) : SValuator(valMgr) {}
-  virtual ~SimpleSValuator() {}
-
-  virtual SVal EvalMinus(NonLoc val);
-  virtual SVal EvalComplement(NonLoc val);
-  virtual SVal EvalBinOpNN(const GRState *state, BinaryOperator::Opcode op,
-                           NonLoc lhs, NonLoc rhs, QualType resultTy);
-  virtual SVal EvalBinOpLL(const GRState *state, BinaryOperator::Opcode op,
-                           Loc lhs, Loc rhs, QualType resultTy);
-  virtual SVal EvalBinOpLN(const GRState *state, BinaryOperator::Opcode op,
-                           Loc lhs, NonLoc rhs, QualType resultTy);
-
-  /// getKnownValue - Evaluates a given SVal. If the SVal has only one possible
-  ///  (integer) value, that value is returned. Otherwise, returns NULL.
-  virtual const llvm::APSInt *getKnownValue(const GRState *state, SVal V);
-  
-  SVal MakeSymIntVal(const SymExpr *LHS, BinaryOperator::Opcode op,
-                     const llvm::APSInt &RHS, QualType resultTy);
-};
-} // end anonymous namespace
-
-SValuator *clang::CreateSimpleSValuator(ValueManager &valMgr) {
-  return new SimpleSValuator(valMgr);
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for Casts.
-//===----------------------------------------------------------------------===//
-
-SVal SimpleSValuator::EvalCastNL(NonLoc val, QualType castTy) {
-
-  bool isLocType = Loc::IsLocType(castTy);
-
-  if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val)) {
-    if (isLocType)
-      return LI->getLoc();
-
-    // FIXME: Correctly support promotions/truncations.
-    ASTContext &Ctx = ValMgr.getContext();
-    unsigned castSize = Ctx.getTypeSize(castTy);
-    if (castSize == LI->getNumBits())
-      return val;
-
-    return ValMgr.makeLocAsInteger(LI->getLoc(), castSize);
-  }
-
-  if (const SymExpr *se = val.getAsSymbolicExpression()) {
-    ASTContext &Ctx = ValMgr.getContext();
-    QualType T = Ctx.getCanonicalType(se->getType(Ctx));
-    if (T == Ctx.getCanonicalType(castTy))
-      return val;
-    
-    // FIXME: Remove this hack when we support symbolic truncation/extension.
-    // HACK: If both castTy and T are integers, ignore the cast.  This is
-    // not a permanent solution.  Eventually we want to precisely handle
-    // extension/truncation of symbolic integers.  This prevents us from losing
-    // precision when we assign 'x = y' and 'y' is symbolic and x and y are
-    // different integer types.
-    if (T->isIntegerType() && castTy->isIntegerType())
-      return val;
-
-    return UnknownVal();
-  }
-
-  if (!isa<nonloc::ConcreteInt>(val))
-    return UnknownVal();
-
-  // Only handle casts from integers to integers.
-  if (!isLocType && !castTy->isIntegerType())
-    return UnknownVal();
-
-  llvm::APSInt i = cast<nonloc::ConcreteInt>(val).getValue();
-  i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
-  i.extOrTrunc(ValMgr.getContext().getTypeSize(castTy));
-
-  if (isLocType)
-    return ValMgr.makeIntLocVal(i);
-  else
-    return ValMgr.makeIntVal(i);
-}
-
-SVal SimpleSValuator::EvalCastL(Loc val, QualType castTy) {
-
-  // Casts from pointers -> pointers, just return the lval.
-  //
-  // Casts from pointers -> references, just return the lval.  These
-  //   can be introduced by the frontend for corner cases, e.g
-  //   casting from va_list* to __builtin_va_list&.
-  //
-  if (Loc::IsLocType(castTy) || castTy->isReferenceType())
-    return val;
-
-  // FIXME: Handle transparent unions where a value can be "transparently"
-  //  lifted into a union type.
-  if (castTy->isUnionType())
-    return UnknownVal();
-
-  if (castTy->isIntegerType()) {
-    unsigned BitWidth = ValMgr.getContext().getTypeSize(castTy);
-
-    if (!isa<loc::ConcreteInt>(val))
-      return ValMgr.makeLocAsInteger(val, BitWidth);
-
-    llvm::APSInt i = cast<loc::ConcreteInt>(val).getValue();
-    i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
-    i.extOrTrunc(BitWidth);
-    return ValMgr.makeIntVal(i);
-  }
-
-  // All other cases: return 'UnknownVal'.  This includes casting pointers
-  // to floats, which is probably badness it itself, but this is a good
-  // intermediate solution until we do something better.
-  return UnknownVal();
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for unary operators.
-//===----------------------------------------------------------------------===//
-
-SVal SimpleSValuator::EvalMinus(NonLoc val) {
-  switch (val.getSubKind()) {
-  case nonloc::ConcreteIntKind:
-    return cast<nonloc::ConcreteInt>(val).evalMinus(ValMgr);
-  default:
-    return UnknownVal();
-  }
-}
-
-SVal SimpleSValuator::EvalComplement(NonLoc X) {
-  switch (X.getSubKind()) {
-  case nonloc::ConcreteIntKind:
-    return cast<nonloc::ConcreteInt>(X).evalComplement(ValMgr);
-  default:
-    return UnknownVal();
-  }
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for binary operators.
-//===----------------------------------------------------------------------===//
-
-static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
-  switch (op) {
-  default:
-    assert(false && "Invalid opcode.");
-  case BO_LT: return BO_GE;
-  case BO_GT: return BO_LE;
-  case BO_LE: return BO_GT;
-  case BO_GE: return BO_LT;
-  case BO_EQ: return BO_NE;
-  case BO_NE: return BO_EQ;
-  }
-}
-
-static BinaryOperator::Opcode ReverseComparison(BinaryOperator::Opcode op) {
-  switch (op) {
-  default:
-    assert(false && "Invalid opcode.");
-  case BO_LT: return BO_GT;
-  case BO_GT: return BO_LT;
-  case BO_LE: return BO_GE;
-  case BO_GE: return BO_LE;
-  case BO_EQ:
-  case BO_NE:
-    return op;
-  }
-}
-
-SVal SimpleSValuator::MakeSymIntVal(const SymExpr *LHS,
-                                    BinaryOperator::Opcode op,
-                                    const llvm::APSInt &RHS,
-                                    QualType resultTy) {
-  bool isIdempotent = false;
-
-  // Check for a few special cases with known reductions first.
-  switch (op) {
-  default:
-    // We can't reduce this case; just treat it normally.
-    break;
-  case BO_Mul:
-    // a*0 and a*1
-    if (RHS == 0)
-      return ValMgr.makeIntVal(0, resultTy);
-    else if (RHS == 1)
-      isIdempotent = true;
-    break;
-  case BO_Div:
-    // a/0 and a/1
-    if (RHS == 0)
-      // This is also handled elsewhere.
-      return UndefinedVal();
-    else if (RHS == 1)
-      isIdempotent = true;
-    break;
-  case BO_Rem:
-    // a%0 and a%1
-    if (RHS == 0)
-      // This is also handled elsewhere.
-      return UndefinedVal();
-    else if (RHS == 1)
-      return ValMgr.makeIntVal(0, resultTy);
-    break;
-  case BO_Add:
-  case BO_Sub:
-  case BO_Shl:
-  case BO_Shr:
-  case BO_Xor:
-    // a+0, a-0, a<<0, a>>0, a^0
-    if (RHS == 0)
-      isIdempotent = true;
-    break;
-  case BO_And:
-    // a&0 and a&(~0)
-    if (RHS == 0)
-      return ValMgr.makeIntVal(0, resultTy);
-    else if (RHS.isAllOnesValue())
-      isIdempotent = true;
-    break;
-  case BO_Or:
-    // a|0 and a|(~0)
-    if (RHS == 0)
-      isIdempotent = true;
-    else if (RHS.isAllOnesValue()) {
-      BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
-      const llvm::APSInt &Result = BVF.Convert(resultTy, RHS);
-      return nonloc::ConcreteInt(Result);
-    }
-    break;
-  }
-
-  // Idempotent ops (like a*1) can still change the type of an expression.
-  // Wrap the LHS up in a NonLoc again and let EvalCastNL do the dirty work.
-  if (isIdempotent) {
-    if (SymbolRef LHSSym = dyn_cast<SymbolData>(LHS))
-      return EvalCastNL(nonloc::SymbolVal(LHSSym), resultTy);
-    return EvalCastNL(nonloc::SymExprVal(LHS), resultTy);
-  }
-
-  // If we reach this point, the expression cannot be simplified.
-  // Make a SymExprVal for the entire thing.
-  return ValMgr.makeNonLoc(LHS, op, RHS, resultTy);
-}
-
-SVal SimpleSValuator::EvalBinOpNN(const GRState *state,
-                                  BinaryOperator::Opcode op,
-                                  NonLoc lhs, NonLoc rhs,
-                                  QualType resultTy)  {
-  // Handle trivial case where left-side and right-side are the same.
-  if (lhs == rhs)
-    switch (op) {
-      default:
-        break;
-      case BO_EQ:
-      case BO_LE:
-      case BO_GE:
-        return ValMgr.makeTruthVal(true, resultTy);
-      case BO_LT:
-      case BO_GT:
-      case BO_NE:
-        return ValMgr.makeTruthVal(false, resultTy);
-      case BO_Xor:
-      case BO_Sub:
-        return ValMgr.makeIntVal(0, resultTy);
-      case BO_Or:
-      case BO_And:
-        return EvalCastNL(lhs, resultTy);
-    }
-
-  while (1) {
-    switch (lhs.getSubKind()) {
-    default:
-      return UnknownVal();
-    case nonloc::LocAsIntegerKind: {
-      Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
-      switch (rhs.getSubKind()) {
-        case nonloc::LocAsIntegerKind:
-          return EvalBinOpLL(state, op, lhsL,
-                             cast<nonloc::LocAsInteger>(rhs).getLoc(),
-                             resultTy);
-        case nonloc::ConcreteIntKind: {
-          // Transform the integer into a location and compare.
-          ASTContext& Ctx = ValMgr.getContext();
-          llvm::APSInt i = cast<nonloc::ConcreteInt>(rhs).getValue();
-          i.setIsUnsigned(true);
-          i.extOrTrunc(Ctx.getTypeSize(Ctx.VoidPtrTy));
-          return EvalBinOpLL(state, op, lhsL, ValMgr.makeLoc(i), resultTy);
-        }
-        default:
-          switch (op) {
-            case BO_EQ:
-              return ValMgr.makeTruthVal(false, resultTy);
-            case BO_NE:
-              return ValMgr.makeTruthVal(true, resultTy);
-            default:
-              // This case also handles pointer arithmetic.
-              return UnknownVal();
-          }
-      }
-    }
-    case nonloc::SymExprValKind: {
-      nonloc::SymExprVal *selhs = cast<nonloc::SymExprVal>(&lhs);
-
-      // Only handle LHS of the form "$sym op constant", at least for now.
-      const SymIntExpr *symIntExpr =
-        dyn_cast<SymIntExpr>(selhs->getSymbolicExpression());
-
-      if (!symIntExpr)
-        return UnknownVal();
-
-      // Is this a logical not? (!x is represented as x == 0.)
-      if (op == BO_EQ && rhs.isZeroConstant()) {
-        // We know how to negate certain expressions. Simplify them here.
-
-        BinaryOperator::Opcode opc = symIntExpr->getOpcode();
-        switch (opc) {
-        default:
-          // We don't know how to negate this operation.
-          // Just handle it as if it were a normal comparison to 0.
-          break;
-        case BO_LAnd:
-        case BO_LOr:
-          assert(false && "Logical operators handled by branching logic.");
-          return UnknownVal();
-        case BO_Assign:
-        case BO_MulAssign:
-        case BO_DivAssign:
-        case BO_RemAssign:
-        case BO_AddAssign:
-        case BO_SubAssign:
-        case BO_ShlAssign:
-        case BO_ShrAssign:
-        case BO_AndAssign:
-        case BO_XorAssign:
-        case BO_OrAssign:
-        case BO_Comma:
-          assert(false && "'=' and ',' operators handled by GRExprEngine.");
-          return UnknownVal();
-        case BO_PtrMemD:
-        case BO_PtrMemI:
-          assert(false && "Pointer arithmetic not handled here.");
-          return UnknownVal();
-        case BO_LT:
-        case BO_GT:
-        case BO_LE:
-        case BO_GE:
-        case BO_EQ:
-        case BO_NE:
-          // Negate the comparison and make a value.
-          opc = NegateComparison(opc);
-          assert(symIntExpr->getType(ValMgr.getContext()) == resultTy);
-          return ValMgr.makeNonLoc(symIntExpr->getLHS(), opc,
-                                   symIntExpr->getRHS(), resultTy);
-        }
-      }
-
-      // For now, only handle expressions whose RHS is a constant.
-      const nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs);
-      if (!rhsInt)
-        return UnknownVal();
-
-      // If both the LHS and the current expression are additive,
-      // fold their constants.
-      if (BinaryOperator::isAdditiveOp(op)) {
-        BinaryOperator::Opcode lop = symIntExpr->getOpcode();
-        if (BinaryOperator::isAdditiveOp(lop)) {
-          BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
-
-          // resultTy may not be the best type to convert to, but it's
-          // probably the best choice in expressions with mixed type
-          // (such as x+1U+2LL). The rules for implicit conversions should
-          // choose a reasonable type to preserve the expression, and will
-          // at least match how the value is going to be used.
-          const llvm::APSInt &first =
-            BVF.Convert(resultTy, symIntExpr->getRHS());
-          const llvm::APSInt &second =
-            BVF.Convert(resultTy, rhsInt->getValue());
-
-          const llvm::APSInt *newRHS;
-          if (lop == op)
-            newRHS = BVF.EvaluateAPSInt(BO_Add, first, second);
-          else
-            newRHS = BVF.EvaluateAPSInt(BO_Sub, first, second);
-          return MakeSymIntVal(symIntExpr->getLHS(), lop, *newRHS, resultTy);
-        }
-      }
-
-      // Otherwise, make a SymExprVal out of the expression.
-      return MakeSymIntVal(symIntExpr, op, rhsInt->getValue(), resultTy);
-    }
-    case nonloc::ConcreteIntKind: {
-      const nonloc::ConcreteInt& lhsInt = cast<nonloc::ConcreteInt>(lhs);
-
-      if (isa<nonloc::ConcreteInt>(rhs)) {
-        return lhsInt.evalBinOp(ValMgr, op, cast<nonloc::ConcreteInt>(rhs));
-      } else {
-        const llvm::APSInt& lhsValue = lhsInt.getValue();
-        
-        // Swap the left and right sides and flip the operator if doing so
-        // allows us to better reason about the expression (this is a form
-        // of expression canonicalization).
-        // While we're at it, catch some special cases for non-commutative ops.
-        NonLoc tmp = rhs;
-        rhs = lhs;
-        lhs = tmp;
-
-        switch (op) {
-          case BO_LT:
-          case BO_GT:
-          case BO_LE:
-          case BO_GE:
-            op = ReverseComparison(op);
-            continue;
-          case BO_EQ:
-          case BO_NE:
-          case BO_Add:
-          case BO_Mul:
-          case BO_And:
-          case BO_Xor:
-          case BO_Or:
-            continue;
-          case BO_Shr:
-            if (lhsValue.isAllOnesValue() && lhsValue.isSigned())
-              // At this point lhs and rhs have been swapped.
-              return rhs;
-            // FALL-THROUGH
-          case BO_Shl:
-            if (lhsValue == 0)
-              // At this point lhs and rhs have been swapped.
-              return rhs;
-            return UnknownVal();
-          default:
-            return UnknownVal();
-        }
-      }
-    }
-    case nonloc::SymbolValKind: {
-      nonloc::SymbolVal *slhs = cast<nonloc::SymbolVal>(&lhs);
-      SymbolRef Sym = slhs->getSymbol();
-
-      ASTContext& Ctx = ValMgr.getContext();
-
-      // Does the symbol simplify to a constant?  If so, "fold" the constant
-      // by setting 'lhs' to a ConcreteInt and try again.
-      if (Sym->getType(Ctx)->isIntegerType())
-        if (const llvm::APSInt *Constant = state->getSymVal(Sym)) {
-          // The symbol evaluates to a constant. If necessary, promote the
-          // folded constant (LHS) to the result type.
-          BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
-          const llvm::APSInt &lhs_I = BVF.Convert(resultTy, *Constant);
-          lhs = nonloc::ConcreteInt(lhs_I);
-          
-          // Also promote the RHS (if necessary).
-
-          // For shifts, it is not necessary to promote the RHS.
-          if (BinaryOperator::isShiftOp(op))
-            continue;
-          
-          // Other operators: do an implicit conversion.  This shouldn't be
-          // necessary once we support truncation/extension of symbolic values.
-          if (nonloc::ConcreteInt *rhs_I = dyn_cast<nonloc::ConcreteInt>(&rhs)){
-            rhs = nonloc::ConcreteInt(BVF.Convert(resultTy, rhs_I->getValue()));
-          }
-          
-          continue;
-        }
-
-      // Is the RHS a symbol we can simplify?
-      if (const nonloc::SymbolVal *srhs = dyn_cast<nonloc::SymbolVal>(&rhs)) {
-        SymbolRef RSym = srhs->getSymbol();
-        if (RSym->getType(Ctx)->isIntegerType()) {
-          if (const llvm::APSInt *Constant = state->getSymVal(RSym)) {
-            // The symbol evaluates to a constant.
-            BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
-            const llvm::APSInt &rhs_I = BVF.Convert(resultTy, *Constant);
-            rhs = nonloc::ConcreteInt(rhs_I);
-          }
-        }
-      }
-
-      if (isa<nonloc::ConcreteInt>(rhs)) {
-        return MakeSymIntVal(slhs->getSymbol(), op,
-                             cast<nonloc::ConcreteInt>(rhs).getValue(),
-                             resultTy);
-      }
-
-      return UnknownVal();
-    }
-    }
-  }
-}
-
-// FIXME: all this logic will change if/when we have MemRegion::getLocation().
-SVal SimpleSValuator::EvalBinOpLL(const GRState *state,
-                                  BinaryOperator::Opcode op,
-                                  Loc lhs, Loc rhs,
-                                  QualType resultTy) {
-  // Only comparisons and subtractions are valid operations on two pointers.
-  // See [C99 6.5.5 through 6.5.14] or [C++0x 5.6 through 5.15].
-  // However, if a pointer is casted to an integer, EvalBinOpNN may end up
-  // calling this function with another operation (PR7527). We don't attempt to
-  // model this for now, but it could be useful, particularly when the
-  // "location" is actually an integer value that's been passed through a void*.
-  if (!(BinaryOperator::isComparisonOp(op) || op == BO_Sub))
-    return UnknownVal();
-
-  // Special cases for when both sides are identical.
-  if (lhs == rhs) {
-    switch (op) {
-    default:
-      assert(false && "Unimplemented operation for two identical values");
-      return UnknownVal();
-    case BO_Sub:
-      return ValMgr.makeZeroVal(resultTy);
-    case BO_EQ:
-    case BO_LE:
-    case BO_GE:
-      return ValMgr.makeTruthVal(true, resultTy);
-    case BO_NE:
-    case BO_LT:
-    case BO_GT:
-      return ValMgr.makeTruthVal(false, resultTy);
-    }
-  }
-
-  switch (lhs.getSubKind()) {
-  default:
-    assert(false && "Ordering not implemented for this Loc.");
-    return UnknownVal();
-
-  case loc::GotoLabelKind:
-    // The only thing we know about labels is that they're non-null.
-    if (rhs.isZeroConstant()) {
-      switch (op) {
-      default:
-        break;
-      case BO_Sub:
-        return EvalCastL(lhs, resultTy);
-      case BO_EQ:
-      case BO_LE:
-      case BO_LT:
-        return ValMgr.makeTruthVal(false, resultTy);
-      case BO_NE:
-      case BO_GT:
-      case BO_GE:
-        return ValMgr.makeTruthVal(true, resultTy);
-      }
-    }
-    // There may be two labels for the same location, and a function region may
-    // have the same address as a label at the start of the function (depending
-    // on the ABI).
-    // FIXME: we can probably do a comparison against other MemRegions, though.
-    // FIXME: is there a way to tell if two labels refer to the same location?
-    return UnknownVal(); 
-
-  case loc::ConcreteIntKind: {
-    // If one of the operands is a symbol and the other is a constant,
-    // build an expression for use by the constraint manager.
-    if (SymbolRef rSym = rhs.getAsLocSymbol()) {
-      // We can only build expressions with symbols on the left,
-      // so we need a reversible operator.
-      if (!BinaryOperator::isComparisonOp(op))
-        return UnknownVal();
-
-      const llvm::APSInt &lVal = cast<loc::ConcreteInt>(lhs).getValue();
-      return ValMgr.makeNonLoc(rSym, ReverseComparison(op), lVal, resultTy);
-    }
-
-    // If both operands are constants, just perform the operation.
-    if (loc::ConcreteInt *rInt = dyn_cast<loc::ConcreteInt>(&rhs)) {
-      BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
-      SVal ResultVal = cast<loc::ConcreteInt>(lhs).EvalBinOp(BVF, op, *rInt);
-      if (Loc *Result = dyn_cast<Loc>(&ResultVal))
-        return EvalCastL(*Result, resultTy);
-      else
-        return UnknownVal();
-    }
-
-    // Special case comparisons against NULL.
-    // This must come after the test if the RHS is a symbol, which is used to
-    // build constraints. The address of any non-symbolic region is guaranteed
-    // to be non-NULL, as is any label.
-    assert(isa<loc::MemRegionVal>(rhs) || isa<loc::GotoLabel>(rhs));
-    if (lhs.isZeroConstant()) {
-      switch (op) {
-      default:
-        break;
-      case BO_EQ:
-      case BO_GT:
-      case BO_GE:
-        return ValMgr.makeTruthVal(false, resultTy);
-      case BO_NE:
-      case BO_LT:
-      case BO_LE:
-        return ValMgr.makeTruthVal(true, resultTy);
-      }
-    }
-
-    // Comparing an arbitrary integer to a region or label address is
-    // completely unknowable.
-    return UnknownVal();
-  }
-  case loc::MemRegionKind: {
-    if (loc::ConcreteInt *rInt = dyn_cast<loc::ConcreteInt>(&rhs)) {
-      // If one of the operands is a symbol and the other is a constant,
-      // build an expression for use by the constraint manager.
-      if (SymbolRef lSym = lhs.getAsLocSymbol())
-        return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
-
-      // Special case comparisons to NULL.
-      // This must come after the test if the LHS is a symbol, which is used to
-      // build constraints. The address of any non-symbolic region is guaranteed
-      // to be non-NULL.
-      if (rInt->isZeroConstant()) {
-        switch (op) {
-        default:
-          break;
-        case BO_Sub:
-          return EvalCastL(lhs, resultTy);
-        case BO_EQ:
-        case BO_LT:
-        case BO_LE:
-          return ValMgr.makeTruthVal(false, resultTy);
-        case BO_NE:
-        case BO_GT:
-        case BO_GE:
-          return ValMgr.makeTruthVal(true, resultTy);
-        }
-      }
-
-      // Comparing a region to an arbitrary integer is completely unknowable.
-      return UnknownVal();
-    }
-
-    // Get both values as regions, if possible.
-    const MemRegion *LeftMR = lhs.getAsRegion();
-    assert(LeftMR && "MemRegionKind SVal doesn't have a region!");
-
-    const MemRegion *RightMR = rhs.getAsRegion();
-    if (!RightMR)
-      // The RHS is probably a label, which in theory could address a region.
-      // FIXME: we can probably make a more useful statement about non-code
-      // regions, though.
-      return UnknownVal();
-
-    // If both values wrap regions, see if they're from different base regions.
-    const MemRegion *LeftBase = LeftMR->getBaseRegion();
-    const MemRegion *RightBase = RightMR->getBaseRegion();
-    if (LeftBase != RightBase &&
-        !isa<SymbolicRegion>(LeftBase) && !isa<SymbolicRegion>(RightBase)) {
-      switch (op) {
-      default:
-        return UnknownVal();
-      case BO_EQ:
-        return ValMgr.makeTruthVal(false, resultTy);
-      case BO_NE:
-        return ValMgr.makeTruthVal(true, resultTy);
-      }
-    }
-
-    // The two regions are from the same base region. See if they're both a
-    // type of region we know how to compare.
-
-    // FIXME: If/when there is a getAsRawOffset() for FieldRegions, this
-    // ElementRegion path and the FieldRegion path below should be unified.
-    if (const ElementRegion *LeftER = dyn_cast<ElementRegion>(LeftMR)) {
-      // First see if the right region is also an ElementRegion.
-      const ElementRegion *RightER = dyn_cast<ElementRegion>(RightMR);
-      if (!RightER)
-        return UnknownVal();
-
-      // Next, see if the two ERs have the same super-region and matching types.
-      // FIXME: This should do something useful even if the types don't match,
-      // though if both indexes are constant the RegionRawOffset path will
-      // give the correct answer.
-      if (LeftER->getSuperRegion() == RightER->getSuperRegion() &&
-          LeftER->getElementType() == RightER->getElementType()) {
-        // Get the left index and cast it to the correct type.
-        // If the index is unknown or undefined, bail out here.
-        SVal LeftIndexVal = LeftER->getIndex();
-        NonLoc *LeftIndex = dyn_cast<NonLoc>(&LeftIndexVal);
-        if (!LeftIndex)
-          return UnknownVal();
-        LeftIndexVal = EvalCastNL(*LeftIndex, resultTy);
-        LeftIndex = dyn_cast<NonLoc>(&LeftIndexVal);
-        if (!LeftIndex)
-          return UnknownVal();
-
-        // Do the same for the right index.
-        SVal RightIndexVal = RightER->getIndex();
-        NonLoc *RightIndex = dyn_cast<NonLoc>(&RightIndexVal);
-        if (!RightIndex)
-          return UnknownVal();
-        RightIndexVal = EvalCastNL(*RightIndex, resultTy);
-        RightIndex = dyn_cast<NonLoc>(&RightIndexVal);
-        if (!RightIndex)
-          return UnknownVal();
-
-        // Actually perform the operation.
-        // EvalBinOpNN expects the two indexes to already be the right type.
-        return EvalBinOpNN(state, op, *LeftIndex, *RightIndex, resultTy);
-      }
-
-      // If the element indexes aren't comparable, see if the raw offsets are.
-      RegionRawOffset LeftOffset = LeftER->getAsArrayOffset();
-      RegionRawOffset RightOffset = RightER->getAsArrayOffset();
-
-      if (LeftOffset.getRegion() != NULL &&
-          LeftOffset.getRegion() == RightOffset.getRegion()) {
-        int64_t left = LeftOffset.getByteOffset();
-        int64_t right = RightOffset.getByteOffset();
-
-        switch (op) {
-        default:
-          return UnknownVal();
-        case BO_LT:
-          return ValMgr.makeTruthVal(left < right, resultTy);
-        case BO_GT:
-          return ValMgr.makeTruthVal(left > right, resultTy);
-        case BO_LE:
-          return ValMgr.makeTruthVal(left <= right, resultTy);
-        case BO_GE:
-          return ValMgr.makeTruthVal(left >= right, resultTy);
-        case BO_EQ:
-          return ValMgr.makeTruthVal(left == right, resultTy);
-        case BO_NE:
-          return ValMgr.makeTruthVal(left != right, resultTy);
-        }
-      }
-
-      // If we get here, we have no way of comparing the ElementRegions.
-      return UnknownVal();
-    }
-
-    // See if both regions are fields of the same structure.
-    // FIXME: This doesn't handle nesting, inheritance, or Objective-C ivars.
-    if (const FieldRegion *LeftFR = dyn_cast<FieldRegion>(LeftMR)) {
-      // Only comparisons are meaningful here!
-      if (!BinaryOperator::isComparisonOp(op))
-        return UnknownVal();
-
-      // First see if the right region is also a FieldRegion.
-      const FieldRegion *RightFR = dyn_cast<FieldRegion>(RightMR);
-      if (!RightFR)
-        return UnknownVal();
-
-      // Next, see if the two FRs have the same super-region.
-      // FIXME: This doesn't handle casts yet, and simply stripping the casts
-      // doesn't help.
-      if (LeftFR->getSuperRegion() != RightFR->getSuperRegion())
-        return UnknownVal();
-
-      const FieldDecl *LeftFD = LeftFR->getDecl();
-      const FieldDecl *RightFD = RightFR->getDecl();
-      const RecordDecl *RD = LeftFD->getParent();
-
-      // Make sure the two FRs are from the same kind of record. Just in case!
-      // FIXME: This is probably where inheritance would be a problem.
-      if (RD != RightFD->getParent())
-        return UnknownVal();
-
-      // We know for sure that the two fields are not the same, since that
-      // would have given us the same SVal.
-      if (op == BO_EQ)
-        return ValMgr.makeTruthVal(false, resultTy);
-      if (op == BO_NE)
-        return ValMgr.makeTruthVal(true, resultTy);
-
-      // Iterate through the fields and see which one comes first.
-      // [C99 6.7.2.1.13] "Within a structure object, the non-bit-field
-      // members and the units in which bit-fields reside have addresses that
-      // increase in the order in which they are declared."
-      bool leftFirst = (op == BO_LT || op == BO_LE);
-      for (RecordDecl::field_iterator I = RD->field_begin(),
-           E = RD->field_end(); I!=E; ++I) {
-        if (*I == LeftFD)
-          return ValMgr.makeTruthVal(leftFirst, resultTy);
-        if (*I == RightFD)
-          return ValMgr.makeTruthVal(!leftFirst, resultTy);
-      }
-
-      assert(false && "Fields not found in parent record's definition");
-    }
-
-    // If we get here, we have no way of comparing the regions.
-    return UnknownVal();
-  }
-  }
-}
-
-SVal SimpleSValuator::EvalBinOpLN(const GRState *state,
-                                  BinaryOperator::Opcode op,
-                                  Loc lhs, NonLoc rhs, QualType resultTy) {
-  // Special case: 'rhs' is an integer that has the same width as a pointer and
-  // we are using the integer location in a comparison.  Normally this cannot be
-  // triggered, but transfer functions like those for OSCommpareAndSwapBarrier32
-  // can generate comparisons that trigger this code.
-  // FIXME: Are all locations guaranteed to have pointer width?
-  if (BinaryOperator::isComparisonOp(op)) {
-    if (nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs)) {
-      const llvm::APSInt *x = &rhsInt->getValue();
-      ASTContext &ctx = ValMgr.getContext();
-      if (ctx.getTypeSize(ctx.VoidPtrTy) == x->getBitWidth()) {
-        // Convert the signedness of the integer (if necessary).
-        if (x->isSigned())
-          x = &ValMgr.getBasicValueFactory().getValue(*x, true);
-
-        return EvalBinOpLL(state, op, lhs, loc::ConcreteInt(*x), resultTy);
-      }
-    }
-  }
-  
-  // We are dealing with pointer arithmetic.
-
-  // Handle pointer arithmetic on constant values.
-  if (nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs)) {
-    if (loc::ConcreteInt *lhsInt = dyn_cast<loc::ConcreteInt>(&lhs)) {
-      const llvm::APSInt &leftI = lhsInt->getValue();
-      assert(leftI.isUnsigned());
-      llvm::APSInt rightI(rhsInt->getValue(), /* isUnsigned */ true);
-
-      // Convert the bitwidth of rightI.  This should deal with overflow
-      // since we are dealing with concrete values.
-      rightI.extOrTrunc(leftI.getBitWidth());
-
-      // Offset the increment by the pointer size.
-      llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
-      rightI *= Multiplicand;
-      
-      // Compute the adjusted pointer.
-      switch (op) {
-        case BO_Add:
-          rightI = leftI + rightI;
-          break;
-        case BO_Sub:
-          rightI = leftI - rightI;
-          break;
-        default:
-          llvm_unreachable("Invalid pointer arithmetic operation");
-      }
-      return loc::ConcreteInt(ValMgr.getBasicValueFactory().getValue(rightI));
-    }
-  }
-  
-
-  // Delegate remaining pointer arithmetic to the StoreManager.
-  return state->getStateManager().getStoreManager().EvalBinOp(op, lhs,
-                                                              rhs, resultTy);
-}
-
-const llvm::APSInt *SimpleSValuator::getKnownValue(const GRState *state,
-                                                   SVal V) {
-  if (V.isUnknownOrUndef())
-    return NULL;
-
-  if (loc::ConcreteInt* X = dyn_cast<loc::ConcreteInt>(&V))
-    return &X->getValue();
-
-  if (nonloc::ConcreteInt* X = dyn_cast<nonloc::ConcreteInt>(&V))
-    return &X->getValue();
-
-  if (SymbolRef Sym = V.getAsSymbol())
-    return state->getSymVal(Sym);
-
-  // FIXME: Add support for SymExprs.
-  return NULL;
-}

Modified: cfe/trunk/lib/Checker/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Store.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/Store.cpp (original)
+++ cfe/trunk/lib/Checker/Store.cpp Wed Dec  1 15:28:31 2010
@@ -225,9 +225,9 @@
   }
   
   if (const Loc *L = dyn_cast<Loc>(&V))
-    return ValMgr.getSValuator().EvalCastL(*L, castTy);
+    return ValMgr.getSValBuilder().EvalCastL(*L, castTy);
   else if (const NonLoc *NL = dyn_cast<NonLoc>(&V))
-    return ValMgr.getSValuator().EvalCastNL(*NL, castTy);
+    return ValMgr.getSValBuilder().EvalCastNL(*NL, castTy);
   
   return V;
 }
@@ -309,7 +309,7 @@
 
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
-  // SValuator here to add the two offsets without checking their types.
+  // SValBuilder here to add the two offsets without checking their types.
   if (!isa<nonloc::ConcreteInt>(Offset)) {
     if (isa<ElementRegion>(BaseRegion->StripCasts()))
       return UnknownVal();

Modified: cfe/trunk/lib/Checker/UnixAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UnixAPIChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/UnixAPIChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UnixAPIChecker.cpp Wed Dec  1 15:28:31 2010
@@ -101,9 +101,9 @@
   NonLoc ocreateFlag =
     cast<NonLoc>(C.getValueManager().makeIntVal(UC.Val_O_CREAT.getValue(),
                                                 oflagsEx->getType()));
-  SVal maskedFlagsUC = C.getSValuator().EvalBinOpNN(state, BO_And,
-                                                    oflags, ocreateFlag,
-                                                    oflagsEx->getType());
+  SVal maskedFlagsUC = C.getSValBuilder().EvalBinOpNN(state, BO_And,
+                                                      oflags, ocreateFlag,
+                                                      oflagsEx->getType());
   if (maskedFlagsUC.isUnknownOrUndef())
     return;
   DefinedSVal maskedFlags = cast<DefinedSVal>(maskedFlagsUC);

Modified: cfe/trunk/lib/Checker/VLASizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/VLASizeChecker.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/VLASizeChecker.cpp (original)
+++ cfe/trunk/lib/Checker/VLASizeChecker.cpp Wed Dec  1 15:28:31 2010
@@ -108,7 +108,7 @@
 
   // Convert the array length to size_t.
   ValueManager &ValMgr = C.getValueManager();
-  SValuator &SV = ValMgr.getSValuator();
+  SValBuilder &SV = ValMgr.getSValBuilder();
   QualType SizeTy = Ctx.getSizeType();
   NonLoc ArrayLength = cast<NonLoc>(SV.EvalCast(sizeD, SizeTy, SE->getType()));
 

Modified: cfe/trunk/lib/Checker/ValueManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/ValueManager.cpp?rev=120605&r1=120604&r2=120605&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/ValueManager.cpp (original)
+++ cfe/trunk/lib/Checker/ValueManager.cpp Wed Dec  1 15:28:31 2010
@@ -67,7 +67,7 @@
       return V;
   }
 
-  return SVator->EvalCastNL(cast<NonLoc>(V), ArrayIndexTy);
+  return svalBuilder->EvalCastNL(cast<NonLoc>(V), ArrayIndexTy);
 }
 
 DefinedOrUnknownSVal 





More information about the cfe-commits mailing list