Don't assert in the analyzer when analyze code does a byte load from a function's address. Fixes PR 8052.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112761 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp
index 595fb6f..19945a7 100644
--- a/lib/Checker/RegionStore.cpp
+++ b/lib/Checker/RegionStore.cpp
@@ -1087,6 +1087,10 @@
return ValMgr.makeIntVal(c, T);
}
}
+
+ // Check for loads from a code text region. For such loads, just give up.
+ if (const CodeTextRegion *cR = dyn_cast<CodeTextRegion>(superR))
+ return UnknownVal();
// Handle the case where we are indexing into a larger scalar object.
// For example, this handles:
diff --git a/lib/Checker/Store.cpp b/lib/Checker/Store.cpp
index 7c80eed..1cb5cd7 100644
--- a/lib/Checker/Store.cpp
+++ b/lib/Checker/Store.cpp
@@ -101,17 +101,10 @@
assert(0 && "Invalid region cast");
break;
}
-
+
case MemRegion::FunctionTextRegionKind:
case MemRegion::BlockTextRegionKind:
- case MemRegion::BlockDataRegionKind: {
- // CodeTextRegion should be cast to only a function or block pointer type,
- // although they can in practice be casted to anything, e.g, void*, char*,
- // etc.
- // Just return the region.
- return R;
- }
-
+ case MemRegion::BlockDataRegionKind:
case MemRegion::StringRegionKind:
// FIXME: Need to handle arbitrary downcasts.
case MemRegion::SymbolicRegionKind: