Skip to content

Commit 00892a4

Browse files
committed
Use llvm::function_ref<> instead of std::optional<llvm::function_ref<>>
1 parent 70db191 commit 00892a4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

mlir/lib/Dialect/EmitC/IR/EmitC.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,9 @@ static LogicalResult verifyInitializationAttribute(Operation *op,
174174
/// In the format string, all `{}` are replaced by Placeholders, except if the
175175
/// `{` is escaped by `{{` - then it doesn't start a placeholder.
176176
template <class ArgType>
177-
FailureOr<SmallVector<ReplacementItem>>
178-
parseFormatString(StringRef toParse, ArgType fmtArgs,
179-
std::optional<llvm::function_ref<mlir::InFlightDiagnostic()>>
180-
emitError = {}) {
177+
FailureOr<SmallVector<ReplacementItem>> parseFormatString(
178+
StringRef toParse, ArgType fmtArgs,
179+
llvm::function_ref<mlir::InFlightDiagnostic()> emitError = {}) {
181180
SmallVector<ReplacementItem> items;
182181

183182
// If there are not operands, the format string is not interpreted.
@@ -200,8 +199,7 @@ parseFormatString(StringRef toParse, ArgType fmtArgs,
200199
continue;
201200
}
202201
if (toParse.size() < 2) {
203-
return (*emitError)()
204-
<< "expected '}' after unescaped '{' at end of string";
202+
return emitError() << "expected '}' after unescaped '{' at end of string";
205203
}
206204
// toParse contains at least two characters and starts with `{`.
207205
char nextChar = toParse[1];
@@ -217,8 +215,8 @@ parseFormatString(StringRef toParse, ArgType fmtArgs,
217215
continue;
218216
}
219217

220-
if (emitError.has_value()) {
221-
return (*emitError)() << "expected '}' after unescaped '{'";
218+
if (emitError) {
219+
return emitError() << "expected '}' after unescaped '{'";
222220
}
223221
return failure();
224222
}

0 commit comments

Comments
 (0)