diff options
author | Jordy Rose <jediknil@belkadan.com> | 2010-08-16 01:15:17 +0000 |
---|---|---|
committer | Jordy Rose <jediknil@belkadan.com> | 2010-08-16 01:15:17 +0000 |
commit | e701117b21356d3c60133315b5bdd50232ec6cca (patch) | |
tree | 73eee84d6aeb34c7ff8e34b9121638e333a13b16 /lib/Checker/Store.cpp | |
parent | c736377543edcfbb00a4150fae79b4d9d9f66849 (diff) |
- Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking.
- Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path.
- Remove ConstraintManager::AssumeInBound.
- Teach RegionStore and FlatStore to ignore those regions for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/Store.cpp')
-rw-r--r-- | lib/Checker/Store.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Checker/Store.cpp b/lib/Checker/Store.cpp index e0e2c3ad7d..7c80eed0ea 100644 --- a/lib/Checker/Store.cpp +++ b/lib/Checker/Store.cpp @@ -284,10 +284,6 @@ SVal StoreManager::getLValueElement(QualType elementType, SVal Offset, if (Base.isUnknownOrUndef() || isa<loc::ConcreteInt>(Base)) return Base; - // Only handle integer offsets... for now. - if (!isa<nonloc::ConcreteInt>(Offset)) - return UnknownVal(); - const MemRegion* BaseRegion = cast<loc::MemRegionVal>(Base).getRegion(); // Pointer of any type can be cast and used as array base. @@ -316,6 +312,19 @@ SVal StoreManager::getLValueElement(QualType elementType, SVal Offset, return UnknownVal(); const llvm::APSInt& BaseIdxI = cast<nonloc::ConcreteInt>(BaseIdx).getValue(); + + // 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. + if (!isa<nonloc::ConcreteInt>(Offset)) { + if (isa<ElementRegion>(BaseRegion->StripCasts())) + return UnknownVal(); + + return loc::MemRegionVal(MRMgr.getElementRegion(elementType, Offset, + ElemR->getSuperRegion(), + Ctx)); + } + const llvm::APSInt& OffI = cast<nonloc::ConcreteInt>(Offset).getValue(); assert(BaseIdxI.isSigned()); |