[cfe-commits] r125396 - /cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
Ted Kremenek
kremenek at apple.com
Fri Feb 11 11:48:19 PST 2011
Author: kremenek
Date: Fri Feb 11 13:48:19 2011
New Revision: 125396
URL: http://llvm.org/viewvc/llvm-project?rev=125396&view=rev
Log:
Remove RegionStoreManager::evalBinOp(), which is now handled by the SValBuilder.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=125396&r1=125395&r2=125396&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Feb 11 13:48:19 2011
@@ -824,125 +824,6 @@
return loc::MemRegionVal(baseReg);
}
-//===----------------------------------------------------------------------===//
-// Pointer arithmetic.
-//===----------------------------------------------------------------------===//
-
-SVal RegionStoreManager::evalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R,
- QualType resultTy) {
- // Assume the base location is MemRegionVal.
- if (!isa<loc::MemRegionVal>(L))
- return UnknownVal();
-
- // Special case for zero RHS.
- if (R.isZeroConstant()) {
- switch (Op) {
- default:
- // Handle it normally.
- break;
- case BO_Add:
- case BO_Sub:
- // FIXME: does this need to be casted to match resultTy?
- return L;
- }
- }
-
- const MemRegion* MR = cast<loc::MemRegionVal>(L).getRegion();
- const ElementRegion *ER = 0;
-
- switch (MR->getKind()) {
- case MemRegion::SymbolicRegionKind: {
- const SymbolicRegion *SR = cast<SymbolicRegion>(MR);
- SymbolRef Sym = SR->getSymbol();
- QualType T = Sym->getType(Ctx);
- QualType EleTy;
-
- if (const PointerType *PT = T->getAs<PointerType>())
- EleTy = PT->getPointeeType();
- else
- EleTy = T->getAs<ObjCObjectPointerType>()->getPointeeType();
-
- const NonLoc &ZeroIdx = svalBuilder.makeZeroArrayIndex();
- ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, Ctx);
- break;
- }
- case MemRegion::AllocaRegionKind: {
- const AllocaRegion *AR = cast<AllocaRegion>(MR);
- QualType EleTy = Ctx.CharTy; // Create an ElementRegion of bytes.
- NonLoc ZeroIdx = svalBuilder.makeZeroArrayIndex();
- ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, Ctx);
- break;
- }
-
- case MemRegion::ElementRegionKind: {
- ER = cast<ElementRegion>(MR);
- break;
- }
-
- // Not yet handled.
- case MemRegion::VarRegionKind:
- case MemRegion::StringRegionKind: {
-
- }
- // Fall-through.
- case MemRegion::CompoundLiteralRegionKind:
- case MemRegion::FieldRegionKind:
- case MemRegion::ObjCIvarRegionKind:
- case MemRegion::CXXTempObjectRegionKind:
- case MemRegion::CXXBaseObjectRegionKind:
- return UnknownVal();
-
- case MemRegion::FunctionTextRegionKind:
- case MemRegion::BlockTextRegionKind:
- case MemRegion::BlockDataRegionKind:
- // Technically this can happen if people do funny things with casts.
- return UnknownVal();
-
- case MemRegion::CXXThisRegionKind:
- assert(0 &&
- "Cannot perform pointer arithmetic on implicit argument 'this'");
- case MemRegion::GenericMemSpaceRegionKind:
- case MemRegion::StackLocalsSpaceRegionKind:
- case MemRegion::StackArgumentsSpaceRegionKind:
- case MemRegion::HeapSpaceRegionKind:
- case MemRegion::NonStaticGlobalSpaceRegionKind:
- case MemRegion::StaticGlobalSpaceRegionKind:
- case MemRegion::UnknownSpaceRegionKind:
- assert(0 && "Cannot perform pointer arithmetic on a MemSpace");
- return UnknownVal();
- }
-
- SVal Idx = ER->getIndex();
- nonloc::ConcreteInt* Base = dyn_cast<nonloc::ConcreteInt>(&Idx);
-
- // For now, only support:
- // (a) concrete integer indices that can easily be resolved
- // (b) 0 + symbolic index
- if (Base) {
- if (nonloc::ConcreteInt *Offset = dyn_cast<nonloc::ConcreteInt>(&R)) {
- // FIXME: Should use SValBuilder here.
- SVal NewIdx =
- Base->evalBinOp(svalBuilder, Op,
- cast<nonloc::ConcreteInt>(svalBuilder.convertToArrayIndex(*Offset)));
-
- if (!isa<NonLoc>(NewIdx))
- return UnknownVal();
-
- const MemRegion* NewER =
- MRMgr.getElementRegion(ER->getElementType(), cast<NonLoc>(NewIdx),
- ER->getSuperRegion(), Ctx);
- return svalBuilder.makeLoc(NewER);
- }
- if (0 == Base->getValue()) {
- const MemRegion* NewER =
- MRMgr.getElementRegion(ER->getElementType(), R,
- ER->getSuperRegion(), Ctx);
- return svalBuilder.makeLoc(NewER);
- }
- }
-
- return UnknownVal();
-}
//===----------------------------------------------------------------------===//
// Loading values from regions.
More information about the cfe-commits
mailing list