[clang] [clang] Compute value dependence for references to structured bindings (PR #212368)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 4 22:27:16 PDT 2026
================
@@ -616,6 +616,31 @@ ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) {
Deps |= ExprDependence::ValueInstantiation;
}
+ // The standard doesn't explicitly specify rules for when individial bindings
+ // a structured binding declaration are value-dependent. Handle them using a
+ // similar rule to the rule for variables:
+ //
+ // - An id-expression referring to a tuple binding is value-dependent if
+ // an id-expression referring to the synthetic variable used to store the
+ // result of get() would be value-dependent.
+ // - An id-expression referring to a non-tuple binding is value-dependent if
+ // an id-expression referring to the synthetic variable used to store the
+ // initializer would be value-dependent.
+ //
+ // Internally, this is equivalent to just checking whether the expression
+ // representing the binding is value-dependent.
+ if (const auto *BD = dyn_cast<BindingDecl>(Decl)) {
----------------
ojhunt wrote:
```cpp
const auto *BD = dyn_cast<BindingDecl>(Decl);
if (!BD)
return Deps;
```
?
This seems like a trivial enough case that an early return is unambiguously cleaner
https://github.com/llvm/llvm-project/pull/212368
More information about the cfe-commits
mailing list