[clang] [CIR] Add if statement support (PR #134333)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 4 13:49:46 PDT 2025


================
@@ -263,6 +264,72 @@ static void terminateBody(CIRGenBuilderTy &builder, mlir::Region &r,
     b->erase();
 }
 
+mlir::LogicalResult CIRGenFunction::emitIfStmt(const IfStmt &s) {
+  mlir::LogicalResult res = mlir::success();
+  // The else branch of a consteval if statement is always the only branch
+  // that can be runtime evaluated.
+  const Stmt *ConstevalExecuted;
+  if (s.isConsteval()) {
+    ConstevalExecuted = s.isNegatedConsteval() ? s.getThen() : s.getElse();
----------------
andykaylor wrote:

Please add test cases for the `consteval` cases supported here.

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


More information about the cfe-commits mailing list