[clang] [Clang] Warning as error for fold expressions over comparison operators (PR #136836)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu May 1 05:02:29 PDT 2025


================
@@ -15050,7 +15050,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
     ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
 
     if (const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
-        BI && BI->isComparisonOp())
+        !ForFoldExpression && BI && BI->isComparisonOp())
----------------
zyn0217 wrote:

The right fold cases are handled by this branch, right? So shall we rename  ForFoldExpression to ForLeftFold or something?

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


More information about the cfe-commits mailing list