[clang] [CIR] Add basic support for operator new (PR #145802)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 26 11:32:43 PDT 2025


================
@@ -95,6 +95,7 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext,
   // TODO(CIR): Should be updated once TypeSizeInfoAttr is upstreamed
   const unsigned sizeTypeSize =
       astContext.getTypeSize(astContext.getSignedSizeType());
+  SizeSizeInBytes = astContext.toCharUnitsFromBits(sizeTypeSize).getQuantity();
----------------
bcardosolopes wrote:

In general this happens for the other unions as well.

We could get rid of the unions by forcing usage to go through helpers (like getSizeSize(), etc) and the helper itself can use the whatever type it's supposed to match, but this requires cleaning up usages beforehand.

Perhaps this cleanup can be done when `TypeSizeInfoAttr` is introduced (at which point we perhaps can kill the `CIRGenTypeCache` altogether, given it should be cheap to grab these types because MLIR value semantics (which is different from the LLVM type representation)).

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


More information about the cfe-commits mailing list