[clang] [Clang] Implement P0963R3 "Structured binding declaration as a condition" (PR #130228)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 10 06:21:17 PDT 2025


================
@@ -5452,6 +5477,11 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
   if (!this->emitSetLocal(CondT, CondVar, S))
     return false;
 
+  if (auto *DD =
+          dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable()))
+    if (!this->emitDecompositionVarInit(DD))
+      return false;
----------------
mizvekov wrote:

Nit:
```suggestion
  if (auto *DD =
          dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable()); DD && !this->emitDecompositionVarInit(DD))
      return false;
```

Maybe also deduplicate with the above.

https://github.com/llvm/llvm-project/pull/130228


More information about the cfe-commits mailing list