@@ -163,14 +163,14 @@ class TypeConverter {
163163
164164 // / All of the following materializations require function objects that are
165165 // / convertible to the following form:
166- // / `std::optional< Value> (OpBuilder &, T, ValueRange, Location)`,
166+ // / `Value(OpBuilder &, T, ValueRange, Location)`,
167167 // / where `T` is any subclass of `Type`. This function is responsible for
168168 // / creating an operation, using the OpBuilder and Location provided, that
169169 // / "casts" a range of values into a single value of the given type `T`. It
170- // / must return a Value of the type `T` on success, an `std::nullopt ` if
171- // / it failed but other materialization can be attempted, and `nullptr` on
172- // / unrecoverable failure. Materialization functions must be provided when a
173- // / type conversion may persist after the conversion has finished.
170+ // / must return a Value of the type `T` on success and `nullptr ` if
171+ // / it failed but other materialization should be attempted. Materialization
172+ // / functions must be provided when a type conversion may persist after the
173+ // / conversion has finished.
174174 // /
175175 // / Note: Target materializations may optionally accept an additional Type
176176 // / parameter, which is the original type of the SSA value.
@@ -335,14 +335,14 @@ class TypeConverter {
335335 // / conversion.
336336 // /
337337 // / Arguments: builder, result type, inputs, location
338- using MaterializationCallbackFn = std::function<std::optional<Value>(
339- OpBuilder &, Type, ValueRange, Location)>;
338+ using MaterializationCallbackFn =
339+ std::function<Value( OpBuilder &, Type, ValueRange, Location)>;
340340
341341 // / The signature of the callback used to materialize a target conversion.
342342 // /
343343 // / Arguments: builder, result type, inputs, location, original type
344- using TargetMaterializationCallbackFn = std::function<std::optional<Value>(
345- OpBuilder &, Type, ValueRange, Location, Type)>;
344+ using TargetMaterializationCallbackFn =
345+ std::function<Value( OpBuilder &, Type, ValueRange, Location, Type)>;
346346
347347 // / The signature of the callback used to convert a type attribute.
348348 using TypeAttributeConversionCallbackFn =
@@ -396,10 +396,10 @@ class TypeConverter {
396396 MaterializationCallbackFn wrapMaterialization (FnT &&callback) const {
397397 return [callback = std::forward<FnT>(callback)](
398398 OpBuilder &builder, Type resultType, ValueRange inputs,
399- Location loc) -> std::optional< Value> {
399+ Location loc) -> Value {
400400 if (T derivedType = dyn_cast<T>(resultType))
401401 return callback (builder, derivedType, inputs, loc);
402- return std:: nullopt ;
402+ return Value () ;
403403 };
404404 }
405405
@@ -417,10 +417,10 @@ class TypeConverter {
417417 wrapTargetMaterialization (FnT &&callback) const {
418418 return [callback = std::forward<FnT>(callback)](
419419 OpBuilder &builder, Type resultType, ValueRange inputs,
420- Location loc, Type originalType) -> std::optional< Value> {
420+ Location loc, Type originalType) -> Value {
421421 if (T derivedType = dyn_cast<T>(resultType))
422422 return callback (builder, derivedType, inputs, loc, originalType);
423- return std:: nullopt ;
423+ return Value () ;
424424 };
425425 }
426426 // / With callback of form:
@@ -433,7 +433,7 @@ class TypeConverter {
433433 return wrapTargetMaterialization<T>(
434434 [callback = std::forward<FnT>(callback)](
435435 OpBuilder &builder, T resultType, ValueRange inputs, Location loc,
436- Type originalType) -> std::optional< Value> {
436+ Type originalType) -> Value {
437437 return callback (builder, resultType, inputs, loc);
438438 });
439439 }
0 commit comments