diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-11-11 23:10:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-11-11 23:10:10 +0000 |
commit | 843c53828fa7ae1f6e121d9ab5352054173ea31d (patch) | |
tree | 9a7ba3d85ca67afc2b3fff3ea6afe48f05a1c956 /clang/lib/Checker/RegionStore.cpp | |
parent | 667429d6b184a00e039de025c8f6fc61b2188b71 (diff) | |
download | bcm5719-llvm-843c53828fa7ae1f6e121d9ab5352054173ea31d.tar.gz bcm5719-llvm-843c53828fa7ae1f6e121d9ab5352054173ea31d.zip |
RegionStore/BasicStore: do not return UndefinedVal for accesses to concrete addresses; instead return UnknownVal. This
leads it up to checkers (e.g., DereferenceChecker) to guard against illegal accesses (e.g., null dereferences).
Fixes PR 5272 and <rdar://problem/6839683>.
llvm-svn: 118852
Diffstat (limited to 'clang/lib/Checker/RegionStore.cpp')
-rw-r--r-- | clang/lib/Checker/RegionStore.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index 231be0af18d..7808872f5dd 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -952,10 +952,15 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { assert(!isa<UnknownVal>(L) && "location unknown"); assert(!isa<UndefinedVal>(L) && "location undefined"); - // FIXME: Is this even possible? Shouldn't this be treated as a null - // dereference at a higher level? - if (isa<loc::ConcreteInt>(L)) - return UndefinedVal(); + // For access to concrete addresses, return UnknownVal. Checks + // for null dereferences (and similar errors) are done by checkers, not + // the Store. + // FIXME: We can consider lazily symbolicating such memory, but we really + // should defer this when we can reason easily about symbolicating arrays + // of bytes. + if (isa<loc::ConcreteInt>(L)) { + return UnknownVal(); + } const MemRegion *MR = cast<loc::MemRegionVal>(L).getRegion(); |