[clang] [clang][CIR] Convert fixed-point values to bool enums like bool (PR #245930)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 03:54:06 PST 2026


================
@@ -1069,7 +1076,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
     // integers, we do not want to follow any logic that assumes they should be
     // treated as integers.
     if (srcType->isFixedPointType()) {
-      if (dstType->isBooleanType()) {
+      if (dstType->hasBooleanConversionSemantics()) {
----------------
xlauko wrote:

Classic codegen switches two more checks to the new helper: `EmitScalarConversion` (`CGExprScalar.cpp:1679`) and `EmitComplexToScalarConversion` (`CGExprScalar.cpp:1887`). Here both still test `isBooleanType()`: the generic check at line 1118, and `CIRGenFunction::emitComplexToScalarConversion` at line 3211. For an `enum E : bool` destination, line 3211 takes the real part only and drops the imaginary part. Can both use `hasBooleanConversionSemantics()` to match classic?

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


More information about the cfe-commits mailing list