Skip to content
Merged
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
14 changes: 6 additions & 8 deletions mlir/lib/Dialect/EmitC/IR/EmitC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ static LogicalResult verifyInitializationAttribute(Operation *op,
/// In the format string, all `{}` are replaced by Placeholders, except if the
/// `{` is escaped by `{{` - then it doesn't start a placeholder.
template <class ArgType>
FailureOr<SmallVector<ReplacementItem>>
parseFormatString(StringRef toParse, ArgType fmtArgs,
std::optional<llvm::function_ref<mlir::InFlightDiagnostic()>>
emitError = {}) {
FailureOr<SmallVector<ReplacementItem>> parseFormatString(
StringRef toParse, ArgType fmtArgs,
llvm::function_ref<mlir::InFlightDiagnostic()> emitError = {}) {
SmallVector<ReplacementItem> items;

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

if (emitError.has_value()) {
return (*emitError)() << "expected '}' after unescaped '{'";
if (emitError) {
return emitError() << "expected '}' after unescaped '{'";
}
return failure();
}
Expand Down
Loading