[clang] [Clang] Handle ?: operator in fold expression (PR #164019)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 30 12:05:36 PST 2025


================
@@ -1510,7 +1510,7 @@ static void CheckFoldOperand(Sema &S, Expr *E) {
   E = E->IgnoreImpCasts();
   auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
   if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
-      isa<AbstractConditionalOperator>(E)) {
+      isa<AbstractConditionalOperator>(E) || isa<RecoveryExpr>(E)) {
----------------
Sirraide wrote:

> IIUC the frontend produces a RecoveryExpr on semantic errors that prevent forming well formed statements. In that case should it be always generated in case of semantic errors? Can you point an example where it is not always generated.

`RecoveryExpr`s are only created if they’re enabled by some flag (`-frecovery-ast` iirc), otherwise, you just get `ExprError()`:
https://github.com/llvm/llvm-project/blob/f42e58f61680e325555f382cab5115c54df6f6df/clang/lib/Sema/SemaExpr.cpp#L21591-L21594

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


More information about the cfe-commits mailing list