diff options
| author | Jordy Rose <jediknil@belkadan.com> | 2010-08-16 20:34:06 +0000 |
|---|---|---|
| committer | Jordy Rose <jediknil@belkadan.com> | 2010-08-16 20:34:06 +0000 |
| commit | 4a57ec86bb8d6a4064887d1f7fc740c91c68416b (patch) | |
| tree | 4af5519049344c53d20e9adc4fb1d78102d59012 | |
| parent | 2bf1fd99b1f75b6cdf6c2d56ce2490db7328dfd3 (diff) | |
| download | bcm5719-llvm-4a57ec86bb8d6a4064887d1f7fc740c91c68416b.tar.gz bcm5719-llvm-4a57ec86bb8d6a4064887d1f7fc740c91c68416b.zip | |
Move GRState::AssumeInBound out of its header file -- it's not really inline-friendly anymore.
llvm-svn: 111179
| -rw-r--r-- | clang/include/clang/Checker/PathSensitive/GRState.h | 44 | ||||
| -rw-r--r-- | clang/lib/Checker/GRState.cpp | 44 |
2 files changed, 44 insertions, 44 deletions
diff --git a/clang/include/clang/Checker/PathSensitive/GRState.h b/clang/include/clang/Checker/PathSensitive/GRState.h index 141ccece26e..984118ea2fa 100644 --- a/clang/include/clang/Checker/PathSensitive/GRState.h +++ b/clang/include/clang/Checker/PathSensitive/GRState.h @@ -612,50 +612,6 @@ GRState::Assume(DefinedOrUnknownSVal Cond) const { 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); } diff --git a/clang/lib/Checker/GRState.cpp b/clang/lib/Checker/GRState.cpp index 21811395d87..37ff87abec1 100644 --- a/clang/lib/Checker/GRState.cpp +++ b/clang/lib/Checker/GRState.cpp @@ -181,6 +181,50 @@ const GRState *GRState::BindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{ 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(), |

