[clang] [analyzer] Refine default binding preservation in RegionStore (PR #189319)
Chandana Mudda via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 22:53:12 PDT 2026
================
@@ -2566,11 +2566,13 @@ RegionStoreManager::setImplicitDefaultValue(LimitedRegionBindingsConstRef B,
if (B.hasExhaustedBindingLimit())
return B;
- // Prefer to keep the previous default binding if we had one; that is likely a
- // better choice than setting some arbitrary new default value.
- // This isn't ideal (more of a hack), but better than dropping the more
- // accurate default binding.
- if (B.getDefaultBinding(R).has_value()) {
+ // Preserve an existing aggregate default binding. This handles partially
+ // initialized union-containing aggregates where bindAggregate() may already
+ // have installed a more precise default value at offset 0. Still allow
+ // implicit defaults for scalars and pointers so regular zero-initialization
+ // continues to work, e.g. for `new int[10]{}`.
+ if ((T->isStructureOrClassType() || T->isArrayType() || T->isUnionType()) &&
----------------
chandmudda wrote:
Thank you, that is a better fit here. The explicit disjunction is broader for C++ record types, while `isAggregateType()` matches the intent expressed in the comment more closely. I will switch to `isAggregateType()`.
https://github.com/llvm/llvm-project/pull/189319
More information about the cfe-commits
mailing list