================
@@ -1889,6 +1889,25 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr 
*ce) {
     }
     return v;
   }
+  case CK_IntegralToPointer: {
+    auto DestCIRTy = cgf.convertType(destTy);
+    mlir::Value Src = Visit(const_cast<Expr *>(subExpr));
+
+    // Properly resize by casting to an int of the same size as the pointer.
+    // Clang's IntegralToPointer includes 'bool' as the source, but in CIR
+    // 'bool' is not an integral type.  So check the source type to get the
+    // correct CIR conversion.
+    auto MiddleTy = cgf.cgm.getDataLayout().getIntPtrType(DestCIRTy);
+    auto MiddleVal = builder.createCast(subExpr->getType()->isBooleanType()
----------------
andykaylor wrote:

```suggestion
    cir::CastOp middleVal = 
builder.createCast(subExpr->getType()->isBooleanType()
```
This is a gray area for `auto` use. If this had been of the form 
`cir::CastOp::create(...)` the use of `auto` would expected. However, some of 
the `builder.create*` functions return `mlir::Value` while others return the 
CIR op type, so `auto` ends up being unclear when that form is called.

https://github.com/llvm/llvm-project/pull/161653
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to