[clang] [CIR][NFC] Simplify BoolAttr builders (PR #136366)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 18 23:57:20 PDT 2025
================
@@ -692,9 +692,7 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite(
// during a pass as long as they don't live past the end of the pass.
attr = op.getValue();
} else if (mlir::isa<cir::BoolType>(op.getType())) {
- int value = (op.getValue() ==
- cir::BoolAttr::get(getContext(),
- cir::BoolType::get(getContext()), true));
+ int value = (op.getValue() == cir::BoolAttr::get(getContext(), true));
----------------
xlauko wrote:
This entire function might be more nicer in terms of cast to attributes directly, not dispatch based on types.
Also nobody guarantees, that if attribute has `cir::BoolType` it is actually `cir::BoolAttr`,
so the previous code might have returned false even in cases that attribute hold "true" value.
I will look into it in next PR.
https://github.com/llvm/llvm-project/pull/136366
More information about the cfe-commits
mailing list