[clang] [clang][analyzer] Preserve symbolic-offset regions across pointer casts (PR #221213)
Radovan Božić via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 08:03:12 PDT 2026
================
@@ -175,10 +175,13 @@ std::optional<const MemRegion *> StoreManager::castRegion(const MemRegion *R,
const RegionRawOffset &rawOff = elementR->getAsArrayOffset();
const MemRegion *baseR = rawOff.getRegion();
- // If we cannot compute a raw offset, throw up our hands and return
- // a NULL MemRegion*.
- if (!baseR)
- return std::nullopt;
+ if (!baseR) {
+ const MemRegion *uncastedR = elementR->StripCasts(false);
+ if (IsSameRegionType(uncastedR, CanonPointeeTy))
+ return uncastedR;
+
+ return MakeElementRegion(cast<SubRegion>(uncastedR), PointeeTy);
+ }
----------------
bozicrHT wrote:
I hadn’t explored whether `getElementRegion()` could canonicalize these chains. I’ll investigate that.
https://github.com/llvm/llvm-project/pull/221213
More information about the cfe-commits
mailing list