diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index 1d5ebdab4f64d..7ca2555b1c2b7 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -166,8 +166,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) { auto valueAttr = mlir::IntegerAttr::get( mlir::IntegerType::get(type.getContext(), 64), value); - return cir::ConstPtrAttr::get( - getContext(), mlir::cast(type), valueAttr); + return cir::ConstPtrAttr::get(type, valueAttr); } mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 293b83e70eff7..cce63c5cae608 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -202,6 +202,11 @@ def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", [TypedAttrInterface]> zeros = typeSize - mlir::cast(elts).size(); return $_get(type.getContext(), type, elts, zeros); + }]>, + AttrBuilderWithInferredContext<(ins "cir::ArrayType":$type, + "mlir::Attribute":$elts, + "int":$trailingZerosNum), [{ + return $_get(type.getContext(), type, elts, trailingZerosNum); }]> ]; @@ -234,11 +239,7 @@ def ConstPtrAttr : CIR_Attr<"ConstPtr", "ptr", [TypedAttrInterface]> { "mlir::IntegerAttr":$value), [{ return $_get(type.getContext(), mlir::cast(type), value); - }]>, - AttrBuilder<(ins "mlir::Type":$type, - "mlir::IntegerAttr":$value), [{ - return $_get($_ctxt, mlir::cast(type), value); - }]>, + }]> ]; let extraClassDeclaration = [{ bool isNullValue() const { return getValue().getInt() == 0; }