From 5251abea41b446c26e3239c8dd6c7edea6fc335d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Feb 2013 05:52:05 +0000 Subject: Replace SVal llvm::cast support to be well-defined. See r175462 for another example/more details. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175594 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/ProgramState.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/StaticAnalyzer/Core/ProgramState.cpp') diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index a3db3764fb..6c76ebfbe5 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -132,7 +132,7 @@ ProgramStateRef ProgramState::bindLoc(Loc LV, SVal V, bool notifyChanges) const ProgramStateRef ProgramState::bindDefault(SVal loc, SVal V) const { ProgramStateManager &Mgr = getStateManager(); - const MemRegion *R = cast(loc).getRegion(); + const MemRegion *R = loc.castAs().getRegion(); const StoreRef &newStore = Mgr.StoreMgr->BindDefault(getStore(), R, V); ProgramStateRef new_state = makeWithStore(newStore); return Mgr.getOwningEngine() ? @@ -189,7 +189,7 @@ ProgramState::invalidateRegionsImpl(ArrayRef Regions, } ProgramStateRef ProgramState::killBinding(Loc LV) const { - assert(!isa(LV) && "Use invalidateRegion instead."); + assert(!LV.getAs() && "Use invalidateRegion instead."); Store OldStore = getStore(); const StoreRef &newStore = @@ -253,7 +253,7 @@ SVal ProgramState::getSVal(Loc location, QualType T) const { // not unsigned. const llvm::APSInt &NewV = getBasicVals().Convert(T, *Int); - if (isa(V)) + if (V.getAs()) return loc::ConcreteInt(NewV); else return nonloc::ConcreteInt(NewV); @@ -301,28 +301,27 @@ ProgramStateRef ProgramState::assumeInBound(DefinedOrUnknownSVal Idx, // Adjust the index. SVal newIdx = svalBuilder.evalBinOpNN(this, BO_Add, - cast(Idx), Min, indexTy); + Idx.castAs(), Min, indexTy); if (newIdx.isUnknownOrUndef()) return this; // Adjust the upper bound. SVal newBound = - svalBuilder.evalBinOpNN(this, BO_Add, cast(UpperBound), + svalBuilder.evalBinOpNN(this, BO_Add, UpperBound.castAs(), Min, indexTy); if (newBound.isUnknownOrUndef()) return this; // Build the actual comparison. - SVal inBound = svalBuilder.evalBinOpNN(this, BO_LT, - cast(newIdx), cast(newBound), - Ctx.IntTy); + SVal inBound = svalBuilder.evalBinOpNN(this, BO_LT, newIdx.castAs(), + newBound.castAs(), 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(inBound), Assumption); + return CM.assume(this, inBound.castAs(), Assumption); } ProgramStateRef ProgramStateManager::getInitialState(const LocationContext *InitLoc) { @@ -509,10 +508,11 @@ bool ScanReachableSymbols::scan(const SymExpr *sym) { } bool ScanReachableSymbols::scan(SVal val) { - if (loc::MemRegionVal *X = dyn_cast(&val)) + if (llvm::Optional X = val.getAs()) return scan(X->getRegion()); - if (nonloc::LazyCompoundVal *X = dyn_cast(&val)) { + if (llvm::Optional X = + val.getAs()) { StoreManager &StoreMgr = state->getStateManager().getStoreManager(); // FIXME: We don't really want to use getBaseRegion() here because pointer // arithmetic doesn't apply, but scanReachableSymbols only accepts base @@ -523,7 +523,8 @@ bool ScanReachableSymbols::scan(SVal val) { return false; } - if (nonloc::LocAsInteger *X = dyn_cast(&val)) + if (llvm::Optional X = + val.getAs()) return scan(X->getLoc()); if (SymbolRef Sym = val.getAsSymbol()) @@ -532,7 +533,7 @@ bool ScanReachableSymbols::scan(SVal val) { if (const SymExpr *Sym = val.getAsSymbolicExpression()) return scan(Sym); - if (nonloc::CompoundVal *X = dyn_cast(&val)) + if (llvm::Optional X = val.getAs()) return scan(*X); return true; -- cgit v1.2.3