[clang] [CIR][NFC] Simplify BoolAttr builders (PR #136366)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 18 23:45:50 PDT 2025


================
@@ -456,9 +456,7 @@ mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
             // scalar type.
             condVal = evaluateExprAsBool(s.getCond());
           } else {
-            cir::BoolType boolTy = cir::BoolType::get(b.getContext());
-            condVal = b.create<cir::ConstantOp>(
-                loc, boolTy, cir::BoolAttr::get(b.getContext(), boolTy, true));
+            condVal = b.create<cir::ConstantOp>(loc, builder.getTrueAttr());
----------------
xlauko wrote:

`b` is `mlir::OpBuilder` here which does not have this method.

It can be done as `CIRBaseBuilderTy(b).getTrue()`.

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


More information about the cfe-commits mailing list