From: Ted Kremenek Date: Tue, 29 Nov 2011 19:39:29 +0000 (+0000) Subject: Relax RegionStore to allow loads from CodeTextRegions. Apparently you can actually... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=214323b78b01ef9c1ad226f0eb5bd1187f3efa70;p=clang Relax RegionStore to allow loads from CodeTextRegions. Apparently you can actually write code that does this. This seems worthy of a checker, but the StoreManager should handle the memory abstraction without crashing. Fixes PR 11450. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145424 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index 4ea465ff2e..27077afada 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -882,7 +882,9 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { const MemRegion *MR = cast(L).getRegion(); - if (isa(MR) || isa(MR)) { + if (isa(MR) || + isa(MR) || + isa(MR)) { if (T.isNull()) { const SymbolicRegion *SR = cast(MR); T = SR->getSymbol()->getType(Ctx); @@ -890,10 +892,6 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { MR = GetElementZeroRegion(MR, T); } - if (isa(MR)) { - llvm_unreachable("Why load from a code text region?"); - } - // FIXME: Perhaps this method should just take a 'const MemRegion*' argument // instead of 'Loc', and have the other Loc cases handled at a higher level. const TypedValueRegion *R = cast(MR); diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index ec760b06ff..df90a7562d 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -484,3 +484,11 @@ void PR11249() *p = 0xDEADBEEF; // no-warning } +// Handle doing a load from the memory associated with the code for +// a function. +extern double nan( const char * ); +double PR11450() { + double NaN = *(double*) nan; + return NaN; +} +