[cfe-commits] r111179 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRState.h lib/Checker/GRState.cpp

Jordy Rose jediknil at belkadan.com
Mon Aug 16 13:34:06 PDT 2010


Author: jrose
Date: Mon Aug 16 15:34:06 2010
New Revision: 111179

URL: http://llvm.org/viewvc/llvm-project?rev=111179&view=rev
Log:
Move GRState::AssumeInBound out of its header file -- it's not really inline-friendly anymore.

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

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRState.h?rev=111179&r1=111178&r2=111179&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRState.h Mon Aug 16 15:34:06 2010
@@ -612,50 +612,6 @@
                                                      cast<DefinedSVal>(Cond));
 }
 
-inline const GRState *GRState::AssumeInBound(DefinedOrUnknownSVal Idx,
-                                             DefinedOrUnknownSVal UpperBound,
-                                             bool Assumption) const {
-  if (Idx.isUnknown() || UpperBound.isUnknown())
-    return this;
-
-  // 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.
-  GRStateManager &SM = getStateManager();
-  ValueManager &VM = SM.getValueManager();
-  SValuator &SV = VM.getSValuator();
-  ASTContext &Ctx = VM.getContext();
-
-  // Get the offset: the minimum value of the array index type.
-  BasicValueFactory &BVF = VM.getBasicValueFactory();
-  // FIXME: This should be using ValueManager::ArrayIndexTy...somehow.
-  QualType IndexTy = Ctx.IntTy;
-  nonloc::ConcreteInt Min = BVF.getMinValue(IndexTy);
-
-  // Adjust the index.
-  SVal NewIdx = SV.EvalBinOpNN(this, BinaryOperator::Add,
-                               cast<NonLoc>(Idx), Min, IndexTy);
-  if (NewIdx.isUnknownOrUndef())
-    return this;
-
-  // Adjust the upper bound.
-  SVal NewBound = SV.EvalBinOpNN(this, BinaryOperator::Add,
-                                 cast<NonLoc>(UpperBound), Min, IndexTy);
-  if (NewBound.isUnknownOrUndef())
-    return this;
-
-  // Build the actual comparison.
-  SVal InBound = SV.EvalBinOpNN(this, BinaryOperator::LT,
-                                cast<NonLoc>(NewIdx), cast<NonLoc>(NewBound),
-                                Ctx.IntTy);
-  if (InBound.isUnknownOrUndef())
-    return this;
-
-  // Finally, let the constraint manager take care of it.
-  ConstraintManager &CM = SM.getConstraintManager();
-  return CM.Assume(this, cast<DefinedSVal>(InBound), Assumption);
-}
-
 inline const GRState *GRState::bindLoc(SVal LV, SVal V) const {
   return !isa<Loc>(LV) ? this : bindLoc(cast<Loc>(LV), V);
 }

Modified: cfe/trunk/lib/Checker/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRState.cpp?rev=111179&r1=111178&r2=111179&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRState.cpp (original)
+++ cfe/trunk/lib/Checker/GRState.cpp Mon Aug 16 15:34:06 2010
@@ -181,6 +181,50 @@
   return getStateManager().getPersistentState(NewSt);
 }
 
+const GRState *GRState::AssumeInBound(DefinedOrUnknownSVal Idx,
+                                      DefinedOrUnknownSVal UpperBound,
+                                      bool Assumption) const {
+  if (Idx.isUnknown() || UpperBound.isUnknown())
+    return this;
+
+  // 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.
+  GRStateManager &SM = getStateManager();
+  ValueManager &VM = SM.getValueManager();
+  SValuator &SV = VM.getSValuator();
+  ASTContext &Ctx = VM.getContext();
+
+  // Get the offset: the minimum value of the array index type.
+  BasicValueFactory &BVF = VM.getBasicValueFactory();
+  // FIXME: This should be using ValueManager::ArrayIndexTy...somehow.
+  QualType IndexTy = Ctx.IntTy;
+  nonloc::ConcreteInt Min = BVF.getMinValue(IndexTy);
+
+  // Adjust the index.
+  SVal NewIdx = SV.EvalBinOpNN(this, BinaryOperator::Add,
+                               cast<NonLoc>(Idx), Min, IndexTy);
+  if (NewIdx.isUnknownOrUndef())
+    return this;
+
+  // Adjust the upper bound.
+  SVal NewBound = SV.EvalBinOpNN(this, BinaryOperator::Add,
+                                 cast<NonLoc>(UpperBound), Min, IndexTy);
+  if (NewBound.isUnknownOrUndef())
+    return this;
+
+  // Build the actual comparison.
+  SVal InBound = SV.EvalBinOpNN(this, BinaryOperator::LT,
+                                cast<NonLoc>(NewIdx), cast<NonLoc>(NewBound),
+                                Ctx.IntTy);
+  if (InBound.isUnknownOrUndef())
+    return this;
+
+  // Finally, let the constraint manager take care of it.
+  ConstraintManager &CM = SM.getConstraintManager();
+  return CM.Assume(this, cast<DefinedSVal>(InBound), Assumption);
+}
+
 const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
   GRState State(this,
                 EnvMgr.getInitialEnvironment(),





More information about the cfe-commits mailing list