]> granicus.if.org Git - clang/commitdiff
Relax RegionStore to allow loads from CodeTextRegions. Apparently you can actually...
authorTed Kremenek <kremenek@apple.com>
Tue, 29 Nov 2011 19:39:29 +0000 (19:39 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 29 Nov 2011 19:39:29 +0000 (19:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/misc-ps-region-store.cpp

index 4ea465ff2e717006d8564bea1aed2c6ad29c1c3e..27077afadaba1dab80187b97002bfee210a86c57 100644 (file)
@@ -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);
index ec760b06ff875dde977d4ba9b7ebf4e94b8a1fda..df90a7562dd9628750a61b381e2d7a9b0fa907ec 100644 (file)
@@ -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;
+}
+