================
@@ -2609,9 +2611,42 @@ RegionBindingsRef 
RegionStoreManager::bindVector(RegionBindingsConstRef B,
   return NewB;
 }
 
+std::optional<SVal>
+RegionStoreManager::getUniqueDefaultBinding(Store S,
+                                            const MemRegion *BaseR) const {
+  assert(BaseR == BaseR->getBaseRegion() && "Expecting a base region");
+  const auto *Cluster = getRegionBindings(S).lookup(BaseR);
+  if (!Cluster || !llvm::hasSingleElement(*Cluster))
+    return std::nullopt;
+
+  const auto [Key, Value] = *Cluster->begin();
+  return Key.isDirect() ? std::optional<SVal>{} : Value;
----------------
NagyDonat wrote:

Ok, that's reasonable, I was just surprised at first glance. As a potential 
alternative I could also imagine an `if` instead of the ternary operator:

```suggestion
    return std::nullopt;

  if (const auto [Key, Value] = *Cluster->begin(); !Key.isDirect())
    return Value;
  return std::nullopt;
```
but the current implementation is also OK.

https://github.com/llvm/llvm-project/pull/115917
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to