@@ -171,10 +171,9 @@ static LogicalResult verifyInitializationAttribute(Operation *op,
171171// / In the format string, all `{}` are replaced by Placeholders, except if the
172172// / `{` is escaped by `{{` - then it doesn't start a placeholder.
173173template <class ArgType >
174- FailureOr<SmallVector<ReplacementItem>>
175- parseFormatString (StringRef toParse, ArgType fmtArgs,
176- std::optional<llvm::function_ref<mlir::InFlightDiagnostic()>>
177- emitError = {}) {
174+ FailureOr<SmallVector<ReplacementItem>> parseFormatString (
175+ StringRef toParse, ArgType fmtArgs,
176+ llvm::function_ref<mlir::InFlightDiagnostic()> emitError = {}) {
178177 SmallVector<ReplacementItem> items;
179178
180179 // If there are not operands, the format string is not interpreted.
@@ -197,8 +196,7 @@ parseFormatString(StringRef toParse, ArgType fmtArgs,
197196 continue ;
198197 }
199198 if (toParse.size () < 2 ) {
200- return (*emitError)()
201- << " expected '}' after unescaped '{' at end of string" ;
199+ return emitError () << " expected '}' after unescaped '{' at end of string" ;
202200 }
203201 // toParse contains at least two characters and starts with `{`.
204202 char nextChar = toParse[1 ];
@@ -214,8 +212,8 @@ parseFormatString(StringRef toParse, ArgType fmtArgs,
214212 continue ;
215213 }
216214
217- if (emitError. has_value () ) {
218- return (* emitError) () << " expected '}' after unescaped '{'" ;
215+ if (emitError) {
216+ return emitError () << " expected '}' after unescaped '{'" ;
219217 }
220218 return failure ();
221219 }
0 commit comments