[clang] [analyzer] Retain address space information in getElementRegion (PR #151370)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 1 07:29:01 PDT 2025
================
@@ -1219,6 +1219,16 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx,
const ASTContext &Ctx) {
QualType T = Ctx.getCanonicalType(elementType).getUnqualifiedType();
+ // The address space must be preserved because some target-specific address
+ // spaces influence the size of the pointer value which is represented by the
+ // element region.
+ LangAS AS = elementType.getAddressSpace();
+ if (AS != LangAS::Default) {
----------------
NagyDonat wrote:
I would prefer keeping the initialization before the `if`, because I feel that limiting the scope of `AS` does not help too much (because this address space handling is clearly separated from the rest of the method + the whole method is not too long), while squeezing the initialization and the `!= LangAS::Default` onto a single line would make it overcrowded and IMO ugly. (There are some cases where limiting the scope is really helpful, but by default I prefer not using init-if.)
However, this is just a bikeshed, so I can recolor it if you want.
https://github.com/llvm/llvm-project/pull/151370
More information about the cfe-commits
mailing list