Skip to content

Commit 4651b68

Browse files
committed
[mlir] Use {} instead of std::nullopt to initialize empty ArrayRef
Follow up to llvm#109133.
1 parent 5b4c80f commit 4651b68

File tree

43 files changed

+75
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+75
-72
lines changed

mlir/include/mlir/AsmParser/AsmParserState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class AsmParserState {
195195
/// Finalize the most recently started operation definition.
196196
void finalizeOperationDefinition(
197197
Operation *op, SMRange nameLoc, SMLoc endLoc,
198-
ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = std::nullopt);
198+
ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = {});
199199

200200
/// Start a definition for a region nested under the current operation.
201201
void startRegionDefinition();

mlir/include/mlir/CAPI/Wrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static llvm::ArrayRef<CppTy> unwrapList(size_t size, CTy *first,
4444
"incompatible C and C++ types");
4545

4646
if (size == 0)
47-
return std::nullopt;
47+
return {};
4848

4949
assert(storage.empty() && "expected to populate storage");
5050
storage.reserve(size);

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
371371
auto *inst = builder.CreateLoad($_resultType, $addr, $volatile_);
372372
$res = inst;
373373
if ($invariant) {
374-
llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), std::nullopt);
374+
llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), {});
375375
inst->setMetadata(llvm::LLVMContext::MD_invariant_load, metadata);
376376
}
377377
}] # setOrderingCode

mlir/include/mlir/Dialect/PDL/IR/PDLOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
363363
let builders = [
364364
OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
365365
CArg<"ValueRange", "std::nullopt">:$operandValues,
366-
CArg<"ArrayRef<StringRef>", "std::nullopt">:$attrNames,
366+
CArg<"ArrayRef<StringRef>", "{}">:$attrNames,
367367
CArg<"ValueRange", "std::nullopt">:$attrValues,
368368
CArg<"ValueRange", "std::nullopt">:$resultTypes), [{
369369
auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr();

mlir/include/mlir/ExecutionEngine/ExecutionEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class ExecutionEngine {
158158
/// Invokes the function with the given name passing it the list of opaque
159159
/// pointers to the actual arguments.
160160
llvm::Error invokePacked(StringRef name,
161-
MutableArrayRef<void *> args = std::nullopt);
161+
MutableArrayRef<void *> args = {});
162162

163163
/// Trait that defines how a given type is passed to the JIT code. This
164164
/// defaults to passing the address but can be specialized.

mlir/include/mlir/IR/BlockSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class BlockRange final
106106
Block *, Block *, Block *> {
107107
public:
108108
using RangeBaseT::RangeBaseT;
109-
BlockRange(ArrayRef<Block *> blocks = std::nullopt);
109+
BlockRange(ArrayRef<Block *> blocks = {});
110110
BlockRange(SuccessorRange successors);
111111
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
112112
ArrayRef<Block *>, Arg>::value>>

mlir/include/mlir/IR/Builders.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,14 @@ class OpBuilder : public Builder {
463463
/// should match the size of `argTypes`.
464464
Block *createBlock(Region *parent, Region::iterator insertPt = {},
465465
TypeRange argTypes = std::nullopt,
466-
ArrayRef<Location> locs = std::nullopt);
466+
ArrayRef<Location> locs = {});
467467

468468
/// Add new block with 'argTypes' arguments and set the insertion point to the
469469
/// end of it. The block is placed before 'insertBefore'. `locs` contains the
470470
/// locations of the inserted arguments, and should match the size of
471471
/// `argTypes`.
472472
Block *createBlock(Block *insertBefore, TypeRange argTypes = std::nullopt,
473-
ArrayRef<Location> locs = std::nullopt);
473+
ArrayRef<Location> locs = {});
474474

475475
//===--------------------------------------------------------------------===//
476476
// Operation Creation

mlir/include/mlir/IR/BuiltinAttributes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", "dictionary"> {
516516
}];
517517
let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value);
518518
let builders = [
519-
AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
519+
AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "{}">:$value)>
520520
];
521521
let extraClassDeclaration = [{
522522
using ValueType = ArrayRef<NamedAttribute>;

mlir/include/mlir/IR/BuiltinTypes.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", "unranked_memref", [
10701070
using ShapedType::Trait<UnrankedMemRefType>::getDimSize;
10711071
using ShapedType::Trait<UnrankedMemRefType>::getDynamicDimIndex;
10721072

1073-
ArrayRef<int64_t> getShape() const { return std::nullopt; }
1073+
ArrayRef<int64_t> getShape() const { return {}; }
10741074

10751075
/// [deprecated] Returns the memory space in old raw integer representation.
10761076
/// New `Attribute getMemorySpace()` method should be used instead.
@@ -1129,7 +1129,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", "unranked_tensor", [
11291129
using ShapedType::Trait<UnrankedTensorType>::getDimSize;
11301130
using ShapedType::Trait<UnrankedTensorType>::getDynamicDimIndex;
11311131

1132-
ArrayRef<int64_t> getShape() const { return std::nullopt; }
1132+
ArrayRef<int64_t> getShape() const { return {}; }
11331133
}];
11341134
let skipDefaultBuilders = 1;
11351135
let genVerifyDecl = 1;

mlir/include/mlir/IR/Matchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct constant_op_binder {
8888

8989
// Fold the constant to an attribute.
9090
SmallVector<OpFoldResult, 1> foldedOp;
91-
LogicalResult result = op->fold(/*operands=*/std::nullopt, foldedOp);
91+
LogicalResult result = op->fold(/*operands=*/{}, foldedOp);
9292
(void)result;
9393
assert(succeeded(result) && "expected ConstantLike op to be foldable");
9494

0 commit comments

Comments
 (0)