diff options
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 8 | ||||
-rw-r--r-- | clang/test/Analysis/misc-ps-region-store.cpp | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 4ea465ff2e7..27077afadab 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -882,7 +882,9 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { const MemRegion *MR = cast<loc::MemRegionVal>(L).getRegion(); - if (isa<AllocaRegion>(MR) || isa<SymbolicRegion>(MR)) { + if (isa<AllocaRegion>(MR) || + isa<SymbolicRegion>(MR) || + isa<CodeTextRegion>(MR)) { if (T.isNull()) { const SymbolicRegion *SR = cast<SymbolicRegion>(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<CodeTextRegion>(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<TypedValueRegion>(MR); diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp index ec760b06ff8..df90a7562dd 100644 --- a/clang/test/Analysis/misc-ps-region-store.cpp +++ b/clang/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; +} + |