Author: Henrich Lauko Date: 2025-04-22T09:08:49+02:00 New Revision: 8639b365a5988932973a82ffe5e620a9c8ef9039
URL: https://github.com/llvm/llvm-project/commit/8639b365a5988932973a82ffe5e620a9c8ef9039 DIFF: https://github.com/llvm/llvm-project/commit/8639b365a5988932973a82ffe5e620a9c8ef9039.diff LOG: [CIR] Make UndefAttr use AttrBuilderWithInferredContext (#136605) This mirrors incubator changes from https://github.com/llvm/clangir/pull/1577 Added: Modified: clang/include/clang/CIR/Dialect/IR/CIRAttrs.td clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp Removed: ################################################################################ diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 214db1b1caeeb..dfe15a10fa54e 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -93,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> { }]; let parameters = (ins AttributeSelfTypeParameter<"">:$type); + + let builders = [ + AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{ + return $_get(type.getContext(), type); + }]> + ]; + let assemblyFormat = [{}]; } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index 9cd5c54e6c19e..fe8a5e7428a81 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,8 +34,8 @@ llvm::SmallVector<MemorySlot> cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create<cir::ConstantOp>( - getLoc(), slot.elemType, builder.getAttr<cir::UndefAttr>(slot.elemType)); + return builder.create<cir::ConstantOp>(getLoc(), slot.elemType, + cir::UndefAttr::get(slot.elemType)); } void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits