[clang] Clang Static Analyzer: Fix stack overflow in template-heavy code (PR #184767)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 5 03:59:55 PST 2026
================
@@ -2743,21 +2795,59 @@ RegionStoreManager::bindVector(LimitedRegionBindingsConstRef B,
const ElementRegion *ER = MRMgr.getElementRegion(ElemType, Idx, R, Ctx);
if (ElemType->isArrayType())
- NewB = bindArray(NewB, ER, *VI);
+ NewB = bindArray(NewB.withRecursionDecreased(), ER, *VI);
else if (ElemType->isStructureOrClassType())
- NewB = bindStruct(NewB, ER, *VI);
+ NewB = bindStruct(NewB.withRecursionDecreased(), ER, *VI);
else
- NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
+ NewB = bind(NewB.withRecursionDecreased(), loc::MemRegionVal(ER), *VI);
}
return NewB;
}
+std::optional<SVal>
+RegionStoreManager::getUniqueDefaultBinding(RegionBindingsConstRef B,
+ const TypedValueRegion *R) const {
+ if (R != R->getBaseRegion())
+ return std::nullopt;
+
+ const auto *Cluster = B.lookup(R);
+ if (!Cluster || !llvm::hasSingleElement(*Cluster))
+ return std::nullopt;
+
+ const auto [Key, Value] = *Cluster->begin();
+ return Key.isDirect() ? std::optional<SVal>{} : Value;
+}
+
+std::optional<SVal>
+RegionStoreManager::getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const {
+ auto B = getRegionBindings(LCV.getStore());
+ return getUniqueDefaultBinding(B, LCV.getRegion());
+}
+
----------------
steakhal wrote:
I figured I've reverted this or similar parts. This suggests to me that there is something wrong with this diff.
https://github.com/llvm/llvm-project/pull/184767
More information about the cfe-commits
mailing list