[clang] [clang][analyzer] Preserve symbolic-offset regions across pointer casts (PR #221213)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 07:01:42 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);
+ }
----------------
steakhal wrote:
Could you guide me through of an example what this does?
In particular, that StripCasts does. I rarely see that API.
https://github.com/llvm/llvm-project/pull/221213
More information about the cfe-commits
mailing list