[mlir] Deprecate NamedAttrList(std::nullopt_t) (NFC) (#149544)

This patch deprecates NamedAttrList(std::nullopt_t) to avoid use of
std::nullopt outside the context of std::optional.
This commit is contained in:
Kazu Hirata
2025-07-18 13:32:56 -07:00
committed by GitHub
parent 36c78ec3c8
commit c98b05bd56
6 changed files with 8 additions and 7 deletions

View File

@@ -802,6 +802,7 @@ public:
using size_type = size_t;
NamedAttrList() : dictionarySorted({}, true) {}
LLVM_DEPRECATED("Use NamedAttrList() instead", "NamedAttrList()")
NamedAttrList(std::nullopt_t none) : NamedAttrList() {}
NamedAttrList(ArrayRef<NamedAttribute> attributes);
NamedAttrList(DictionaryAttr attributes);

View File

@@ -1198,8 +1198,8 @@ Value OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) {
auto name = OperationName("builtin.unrealized_conversion_cast", getContext());
auto *op = Operation::create(
getEncodedSourceLocation(loc), name, type, /*operands=*/{},
/*attributes=*/std::nullopt, /*properties=*/nullptr, /*successors=*/{},
/*numRegions=*/0);
/*attributes=*/NamedAttrList(), /*properties=*/nullptr,
/*successors=*/{}, /*numRegions=*/0);
forwardRefPlaceholders[op->getResult(0)] = loc;
forwardRefOps.insert(op);
return op->getResult(0);

View File

@@ -24,7 +24,7 @@ static Operation *createOp(MLIRContext *context, Location loc,
unsigned int numRegions = 0) {
context->allowUnregisteredDialects();
return Operation::create(loc, OperationName(operationName, context), {}, {},
std::nullopt, OpaqueProperties(nullptr), {},
NamedAttrList(), OpaqueProperties(nullptr), {},
numRegions);
}

View File

@@ -24,7 +24,7 @@ static Operation *createOp(MLIRContext *context, ArrayRef<Value> operands = {},
context->allowUnregisteredDialects();
return Operation::create(UnknownLoc::get(context),
OperationName("foo.bar", context), resultTypes,
operands, std::nullopt, nullptr, {}, numRegions);
operands, NamedAttrList(), nullptr, {}, numRegions);
}
namespace {
@@ -236,7 +236,7 @@ TEST(OperationFormatPrintTest, CanPrintNameAsPrefix) {
Operation *op = Operation::create(
NameLoc::get(StringAttr::get(&context, "my_named_loc")),
OperationName("t.op", &context), builder.getIntegerType(16), {},
std::nullopt, nullptr, {}, 0);
NamedAttrList(), nullptr, {}, 0);
std::string str;
OpPrintingFlags flags;

View File

@@ -22,7 +22,7 @@ static Operation *createOp(MLIRContext *context, ArrayRef<Value> operands = {},
context->allowUnregisteredDialects();
return Operation::create(UnknownLoc::get(context),
OperationName("foo.bar", context), resultTypes,
operands, std::nullopt, nullptr, {}, numRegions);
operands, NamedAttrList(), nullptr, {}, numRegions);
}
namespace {

View File

@@ -15,7 +15,7 @@ static Operation *createOp(MLIRContext *context) {
context->allowUnregisteredDialects();
return Operation::create(UnknownLoc::get(context),
OperationName("foo.bar", context), {}, {},
std::nullopt, /*properties=*/nullptr, {}, 0);
NamedAttrList(), /*properties=*/nullptr, {}, 0);
}
namespace {