Skip to content

[mlir] Use {} instead of std::nullopt to initialize empty ArrayRef #109527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/include/mlir/AsmParser/AsmParserState.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class AsmParserState {
/// Finalize the most recently started operation definition.
void finalizeOperationDefinition(
Operation *op, SMRange nameLoc, SMLoc endLoc,
ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = std::nullopt);
ArrayRef<std::pair<unsigned, SMLoc>> resultGroups = {});

/// Start a definition for a region nested under the current operation.
void startRegionDefinition();
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/CAPI/Wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static llvm::ArrayRef<CppTy> unwrapList(size_t size, CTy *first,
"incompatible C and C++ types");

if (size == 0)
return std::nullopt;
return {};

assert(storage.empty() && "expected to populate storage");
storage.reserve(size);
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
auto *inst = builder.CreateLoad($_resultType, $addr, $volatile_);
$res = inst;
if ($invariant) {
llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), std::nullopt);
llvm::MDNode *metadata = llvm::MDNode::get(inst->getContext(), {});
inst->setMetadata(llvm::LLVMContext::MD_invariant_load, metadata);
}
}] # setOrderingCode
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
let builders = [
OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
CArg<"ValueRange", "std::nullopt">:$operandValues,
CArg<"ArrayRef<StringRef>", "std::nullopt">:$attrNames,
CArg<"ArrayRef<StringRef>", "{}">:$attrNames,
CArg<"ValueRange", "std::nullopt">:$attrValues,
CArg<"ValueRange", "std::nullopt">:$resultTypes), [{
auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr();
Expand Down
3 changes: 1 addition & 2 deletions mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ class ExecutionEngine {

/// Invokes the function with the given name passing it the list of opaque
/// pointers to the actual arguments.
llvm::Error invokePacked(StringRef name,
MutableArrayRef<void *> args = std::nullopt);
llvm::Error invokePacked(StringRef name, MutableArrayRef<void *> args = {});

/// Trait that defines how a given type is passed to the JIT code. This
/// defaults to passing the address but can be specialized.
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/BlockSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class BlockRange final
Block *, Block *, Block *> {
public:
using RangeBaseT::RangeBaseT;
BlockRange(ArrayRef<Block *> blocks = std::nullopt);
BlockRange(ArrayRef<Block *> blocks = {});
BlockRange(SuccessorRange successors);
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<Block *>, Arg>::value>>
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/IR/Builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ class OpBuilder : public Builder {
/// should match the size of `argTypes`.
Block *createBlock(Region *parent, Region::iterator insertPt = {},
TypeRange argTypes = std::nullopt,
ArrayRef<Location> locs = std::nullopt);
ArrayRef<Location> locs = {});

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

//===--------------------------------------------------------------------===//
// Operation Creation
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/BuiltinAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", "dictionary"> {
}];
let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value);
let builders = [
AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "{}">:$value)>
];
let extraClassDeclaration = [{
using ValueType = ArrayRef<NamedAttribute>;
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/IR/BuiltinTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", "unranked_memref", [
using ShapedType::Trait<UnrankedMemRefType>::getDimSize;
using ShapedType::Trait<UnrankedMemRefType>::getDynamicDimIndex;

ArrayRef<int64_t> getShape() const { return std::nullopt; }
ArrayRef<int64_t> getShape() const { return {}; }

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

ArrayRef<int64_t> getShape() const { return std::nullopt; }
ArrayRef<int64_t> getShape() const { return {}; }
}];
let skipDefaultBuilders = 1;
let genVerifyDecl = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/Matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct constant_op_binder {

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

Expand Down
5 changes: 2 additions & 3 deletions mlir/include/mlir/IR/PatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,7 @@ class RewritePatternSet {
RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) {
// The following expands a call to emplace_back for each of the pattern
// types 'Ts'.
(addImpl<Ts>(/*debugLabels=*/std::nullopt,
std::forward<ConstructorArg>(arg),
(addImpl<Ts>(/*debugLabels=*/{}, std::forward<ConstructorArg>(arg),
std::forward<ConstructorArgs>(args)...),
...);
return *this;
Expand Down Expand Up @@ -937,7 +936,7 @@ class RewritePatternSet {
RewritePatternSet &insert(ConstructorArg &&arg, ConstructorArgs &&...args) {
// The following expands a call to emplace_back for each of the pattern
// types 'Ts'.
(addImpl<Ts>(/*debugLabels=*/std::nullopt, arg, args...), ...);
(addImpl<Ts>(/*debugLabels=*/{}, arg, args...), ...);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class RegionRange
public:
using RangeBaseT::RangeBaseT;

RegionRange(MutableArrayRef<Region> regions = std::nullopt);
RegionRange(MutableArrayRef<Region> regions = {});

template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<std::unique_ptr<Region>>, Arg>::value>>
Expand Down
3 changes: 2 additions & 1 deletion mlir/include/mlir/IR/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ class SymbolUserMap {
/// Return the users of the provided symbol operation.
ArrayRef<Operation *> getUsers(Operation *symbol) const {
auto it = symbolToUsers.find(symbol);
return it != symbolToUsers.end() ? it->second.getArrayRef() : std::nullopt;
return it != symbolToUsers.end() ? it->second.getArrayRef()
: ArrayRef<Operation *>();
}

/// Return true if the given symbol has no uses.
Expand Down
3 changes: 2 additions & 1 deletion mlir/include/mlir/IR/TypeRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
Type, Type, Type> {
public:
using RangeBaseT::RangeBaseT;
TypeRange(ArrayRef<Type> types = std::nullopt);
TypeRange(ArrayRef<Type> types = {});
explicit TypeRange(OperandRange values);
explicit TypeRange(ResultRange values);
explicit TypeRange(ValueRange values);
Expand All @@ -47,6 +47,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
template <typename Arg, typename = std::enable_if_t<std::is_constructible<
ArrayRef<Type>, Arg>::value>>
TypeRange(Arg &&arg) : TypeRange(ArrayRef<Type>(std::forward<Arg>(arg))) {}
TypeRange(std::nullopt_t) : TypeRange(ArrayRef<Type>()) {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For TypeRange and ValueRange I opted to allow clients to continue to pass in std::nullopt to get an empty range, to avoid chasing too far down the rabbit hole.

TypeRange(std::initializer_list<Type> types)
: TypeRange(ArrayRef<Type>(types)) {}

Expand Down
5 changes: 3 additions & 2 deletions mlir/include/mlir/IR/ValueRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MutableOperandRange {
/// and range length. `operandSegments` is an optional set of operand segments
/// to be updated when mutating the operand list.
MutableOperandRange(Operation *owner, unsigned start, unsigned length,
ArrayRef<OperandSegment> operandSegments = std::nullopt);
ArrayRef<OperandSegment> operandSegments = {});
MutableOperandRange(Operation *owner);

/// Construct a new mutable range for the given OpOperand.
Expand Down Expand Up @@ -392,6 +392,7 @@ class ValueRange final
std::is_constructible<ArrayRef<Value>, Arg>::value &&
!std::is_convertible<Arg, Value>::value>>
ValueRange(Arg &&arg) : ValueRange(ArrayRef<Value>(std::forward<Arg>(arg))) {}
ValueRange(std::nullopt_t) : ValueRange(ArrayRef<Value>()) {}
ValueRange(const Value &value) : ValueRange(&value, /*count=*/1) {}
ValueRange(const std::initializer_list<Value> &values)
: ValueRange(ArrayRef<Value>(values)) {}
Expand All @@ -401,7 +402,7 @@ class ValueRange final
: ValueRange(ResultRange(values)) {}
ValueRange(ArrayRef<BlockArgument> values)
: ValueRange(ArrayRef<Value>(values.data(), values.size())) {}
ValueRange(ArrayRef<Value> values = std::nullopt);
ValueRange(ArrayRef<Value> values = {});
ValueRange(OperandRange values);
ValueRange(ResultRange values);

Expand Down
7 changes: 3 additions & 4 deletions mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class FrozenRewritePatternSet {
/// `RewritePatternSet::addWithLabel`. Debug names may be empty, but patterns
/// created with `RewritePattern::create` have their default debug name set to
/// their type name.
FrozenRewritePatternSet(
RewritePatternSet &&patterns,
ArrayRef<std::string> disabledPatternLabels = std::nullopt,
ArrayRef<std::string> enabledPatternLabels = std::nullopt);
FrozenRewritePatternSet(RewritePatternSet &&patterns,
ArrayRef<std::string> disabledPatternLabels = {},
ArrayRef<std::string> enabledPatternLabels = {});

/// Return the op specific native patterns held by this list.
const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const {
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Support/StorageUniquer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class StorageUniquer {
template <typename T>
ArrayRef<T> copyInto(ArrayRef<T> elements) {
if (elements.empty())
return std::nullopt;
return {};
auto result = allocator.Allocate<T>(elements.size());
std::uninitialized_copy(elements.begin(), elements.end(), result);
return ArrayRef<T>(result, elements.size());
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Tools/PDLL/AST/Nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,8 @@ class UserConstraintDecl final
ArrayRef<VariableDecl *> results,
const CompoundStmt *body,
Type resultType) {
return createImpl(ctx, name, inputs, /*nativeInputTypes=*/std::nullopt,
results, /*codeBlock=*/std::nullopt, body, resultType);
return createImpl(ctx, name, inputs, /*nativeInputTypes=*/{}, results,
/*codeBlock=*/std::nullopt, body, resultType);
}

/// Return the name of the constraint.
Expand Down
3 changes: 1 addition & 2 deletions mlir/include/mlir/Tools/PDLL/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ class TupleType : public Type::TypeBase<detail::TupleTypeStorage> {
/// Return an instance of the Tuple type.
static TupleType get(Context &context, ArrayRef<Type> elementTypes,
ArrayRef<StringRef> elementNames);
static TupleType get(Context &context,
ArrayRef<Type> elementTypes = std::nullopt);
static TupleType get(Context &context, ArrayRef<Type> elementTypes = {});

/// Return the element types of this tuple.
ArrayRef<Type> getElementTypes() const;
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ std::unique_ptr<Pass> createCanonicalizerPass();
/// set to their type name.
std::unique_ptr<Pass>
createCanonicalizerPass(const GreedyRewriteConfig &config,
ArrayRef<std::string> disabledPatterns = std::nullopt,
ArrayRef<std::string> enabledPatterns = std::nullopt);
ArrayRef<std::string> disabledPatterns = {},
ArrayRef<std::string> enabledPatterns = {});

/// Creates a pass to perform control-flow sinking.
std::unique_ptr<Pass> createControlFlowSinkPass();
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ void PDLToPDLInterpPass::runOnOperation() {
module.getLoc(), pdl_interp::PDLInterpDialect::getMatcherFunctionName(),
builder.getFunctionType(builder.getType<pdl::OperationType>(),
/*results=*/std::nullopt),
/*attrs=*/std::nullopt);
/*attrs=*/ArrayRef<NamedAttribute>());

// Create a nested module to hold the functions invoked for rewriting the IR
// after a successful match.
Expand Down
16 changes: 8 additions & 8 deletions mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static Value createLinalgBodyCalculationForElementwiseOp(
auto shifted =
rewriter.create<arith::ShRSIOp>(loc, resultTypes, args[0], subtract)
->getResults();
auto truncated =
rewriter.create<arith::TruncIOp>(loc, i1Ty, shifted, std::nullopt);
auto truncated = rewriter.create<arith::TruncIOp>(
loc, i1Ty, shifted, llvm::ArrayRef<NamedAttribute>());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, you can't use {} in calls to create<> because the arguments get passed on with std::forward which does not work with initializer lists - but I'm not an expert.

auto isInputOdd =
rewriter.create<arith::AndIOp>(loc, i1Ty, truncated, i1one);

Expand Down Expand Up @@ -447,20 +447,20 @@ static Value createLinalgBodyCalculationForElementwiseOp(

if (isa<FloatType>(srcTy) && isa<FloatType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtFOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

if (isa<FloatType>(srcTy) && isa<FloatType>(dstTy) && !bitExtend)
return rewriter.create<arith::TruncFOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

// 1-bit integers need to be treated as signless.
if (srcTy.isInteger(1) && arith::UIToFPOp::areCastCompatible(srcTy, dstTy))
return rewriter.create<arith::UIToFPOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

if (srcTy.isInteger(1) && isa<IntegerType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtUIOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

// Unsigned integers need an unrealized cast so that they can be passed
// to UIToFP.
Expand All @@ -478,7 +478,7 @@ static Value createLinalgBodyCalculationForElementwiseOp(
// All other si-to-fp conversions should be handled by SIToFP.
if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy))
return rewriter.create<arith::SIToFPOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

// Casting to boolean, floats need to only be checked as not-equal to zero.
if (isa<FloatType>(srcTy) && dstTy.isInteger(1)) {
Expand Down Expand Up @@ -585,7 +585,7 @@ static Value createLinalgBodyCalculationForElementwiseOp(

if (isa<IntegerType>(srcTy) && isa<IntegerType>(dstTy) && bitExtend)
return rewriter.create<arith::ExtSIOp>(loc, resultTypes, args,
std::nullopt);
llvm::ArrayRef<NamedAttribute>());

if (isa<IntegerType>(srcTy) && isa<IntegerType>(dstTy) && !bitExtend) {
return rewriter.create<arith::TruncIOp>(loc, dstTy, args[0]);
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Async/IR/Async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/EmitC/IR/EmitC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Func/IR/FuncOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}

Expand Down
7 changes: 4 additions & 3 deletions mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool isInsideLaunch(Operation *op) {
static std::tuple<Value, OpFoldResult, SmallVector<OpFoldResult>>
getFlatOffsetAndStrides(OpBuilder &rewriter, Location loc, Value source,
ArrayRef<OpFoldResult> subOffsets,
ArrayRef<OpFoldResult> subStrides = std::nullopt) {
ArrayRef<OpFoldResult> subStrides = {}) {
auto sourceType = cast<MemRefType>(source.getType());
auto sourceRank = static_cast<unsigned>(sourceType.getRank());

Expand Down Expand Up @@ -110,8 +110,9 @@ static Value getFlatMemref(OpBuilder &rewriter, Location loc, Value source,
auto &&[base, offset, ignore] =
getFlatOffsetAndStrides(rewriter, loc, source, offsetsTemp);
MemRefType retType = inferCastResultType(base, offset);
return rewriter.create<memref::ReinterpretCastOp>(loc, retType, base, offset,
std::nullopt, std::nullopt);
return rewriter.create<memref::ReinterpretCastOp>(
loc, retType, base, offset, llvm::ArrayRef<OpFoldResult>(),
llvm::ArrayRef<OpFoldResult>());
}

static bool needFlatten(Value val) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,7 @@ void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
assert(llvm::cast<LLVMFunctionType>(type).getNumParams() == argAttrs.size() &&
"expected as many argument attribute lists as arguments");
function_interface_impl::addArgAndResultAttrs(
builder, result, argAttrs, /*resultAttrs=*/std::nullopt,
builder, result, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(result.name), getResAttrsAttrName(result.name));
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct LLVMStructTypeStorage : public TypeStorage {
class Key {
public:
/// Constructs a key for an identified struct.
Key(StringRef name, bool opaque, ArrayRef<Type> types = std::nullopt)
Key(StringRef name, bool opaque, ArrayRef<Type> types = {})
: types(types), name(name), identified(true), packed(false),
opaque(opaque) {}
/// Constructs a key for a literal struct.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Shape/IR/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name,
return;
assert(type.getNumInputs() == argAttrs.size());
function_interface_impl::addArgAndResultAttrs(
builder, state, argAttrs, /*resultAttrs=*/std::nullopt,
builder, state, argAttrs, /*resultAttrs=*/{},
getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/IR/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ SourceMgrDiagnosticVerifierHandlerImpl::computeExpectedDiags(
raw_ostream &os, llvm::SourceMgr &mgr, const llvm::MemoryBuffer *buf) {
// If the buffer is invalid, return an empty list.
if (!buf)
return std::nullopt;
return {};
auto &expectedDiags = expectedDiagsPerFile[buf->getBufferIdentifier()];

// The number of the last line that did not correlate to a designator.
Expand Down
Loading
Loading