[clang] [Clang] Correctly handle allocations in the condition of a `if constexpr` (PR #146890)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 3 08:03:20 PDT 2025


================
@@ -20643,10 +20641,12 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
                               {SubExpr}, PreferredConditionType(CK));
     if (!Cond.get())
       return ConditionError();
-  }
-  if (!isa<FullExpr>(Cond.get()))
+  } else if (Cond.isUsable() && !isa<FullExpr>(Cond.get()))
     Cond = ActOnFinishFullExpr(Cond.get(), Loc, /*DiscardedValue*/ false);
 
+  if (Cond.isInvalid())
----------------
erichkeane wrote:

```suggestion
  if (!Cond.isUsable())
```
Unless there is a reason that `ConditionResult` would be ok with a 'null' expr?

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


More information about the cfe-commits mailing list