[mlir] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
Kazu Hirata 2022-12-04 19:58:32 -08:00
parent 595f1a6aaf
commit 192d9dd731
41 changed files with 112 additions and 105 deletions

View File

@ -301,15 +301,15 @@ class TypeConverter {
/// to any of the following forms(where `T` is a class derived from `Type`:
/// * Optional<Type>(T)
/// - This form represents a 1-1 type conversion. It should return nullptr
/// or `llvm::None` to signify failure. If `llvm::None` is returned, the
/// or `std::nullopt` to signify failure. If `std::nullopt` is returned, the
/// converter is allowed to try another conversion function to perform
/// the conversion.
/// * Optional<LogicalResult>(T, SmallVectorImpl<Type> &)
/// - This form represents a 1-N type conversion. It should return
/// `failure` or `llvm::None` to signify a failed conversion. If the new
/// `failure` or `std::nullopt` to signify a failed conversion. If the new
/// set of types is empty, the type is removed and any usages of the
/// existing value are expected to be removed during conversion. If
/// `llvm::None` is returned, the converter is allowed to try another
/// `std::nullopt` is returned, the converter is allowed to try another
/// conversion function to perform the conversion.
/// * Optional<LogicalResult>(T, SmallVectorImpl<Type> &, ArrayRef<Type>)
/// - This form represents a 1-N type conversion supporting recursive
@ -334,7 +334,7 @@ class TypeConverter {
/// This function is responsible for creating an operation, using the
/// OpBuilder and Location provided, that "converts" a range of values into a
/// single value of the given type `T`. It must return a Value of the
/// converted type on success, an `llvm::None` if it failed but other
/// converted type on success, an `std::nullopt` if it failed but other
/// materialization can be attempted, and `nullptr` on unrecoverable failure.
/// It will only be called for (sub)types of `T`.
///

View File

@ -779,7 +779,7 @@ public:
/// tableau A and one in B.
static Simplex makeProduct(const Simplex &a, const Simplex &b);
/// Returns an integer sample point if one exists, or None
/// Returns an integer sample point if one exists, or std::nullopt
/// otherwise. This should only be called for bounded sets.
Optional<SmallVector<MPInt, 8>> findIntegerSample();

View File

@ -139,7 +139,7 @@ private:
/// if each slice dimension maps to an existing dst dimension and both the src
/// and the dst loops for those dimensions have the same bounds. Returns false
/// if both the src and the dst loops don't have the same bounds. Returns
/// llvm::None if none of the above can be proven.
/// std::nullopt if none of the above can be proven.
Optional<bool> isSliceMaximalFastCheck() const;
};

View File

@ -230,7 +230,7 @@ struct BufferizationOptions {
bool bufferizeFunctionBoundaries = false;
/// The default memory space that should be used when it cannot be inferred
/// from the context. If case of llvm::None, bufferization fails when the
/// from the context. If case of std::nullopt, bufferization fails when the
/// memory space cannot be inferred at any point.
Optional<Attribute> defaultMemorySpace = Attribute();

View File

@ -94,7 +94,7 @@ public:
return std::nullopt;
}
// Return the result number if the `opView` is an OpResult. Otherwise return
// llvm::None.
// std::nullopt.
static Optional<unsigned> getResultNumber(OpView opView) {
if (OpResult result = opView.dyn_cast<Value>().cast<OpResult>())
return result.getResultNumber();
@ -114,13 +114,13 @@ public:
Value getIndexingValue() const { return getValue(indexingOpView); }
// If the dependent OpView is an operand, return operand number. Return
// llvm::None otherwise.
// std::nullopt otherwise.
Optional<unsigned> getDependentOpViewOperandNum() const {
return getOperandNumber(dependentOpView);
}
// If the indexing OpView is an operand, return operand number. Return
// llvm::None otherwise.
// std::nullopt otherwise.
Optional<unsigned> getIndexingOpViewOperandNum() const {
return getOperandNumber(indexingOpView);
}

View File

@ -184,7 +184,7 @@ std::pair<TilingInterface, TilingInterface> splitOp(RewriterBase &rewriter,
/// transformation returns early.
///
/// Return a struct containing the tiled loops in the specified order
/// and the cloned op if successful, llvm::None otherwise.
/// and the cloned op if successful, std::nullopt otherwise.
///
/// E.g. the permutation `(i,j,k) -> (j,k,i)` is expressed by
/// `interchangeVector = [1,2,0]`. All values in `interchangeVector` must be

View File

@ -138,7 +138,7 @@ Optional<SmallVector<ReassociationIndices>>
getReassociationMapForFoldingUnitDims(ArrayRef<OpFoldResult> mixedSizes);
/// Return the identity numeric value associated to the give op. Return
/// llvm::None if there is no known neutral element.
/// std::nullopt if there is no known neutral element.
Optional<Attribute> getNeutralElement(Operation *op);
//===----------------------------------------------------------------------===//
@ -222,7 +222,7 @@ computeSliceParameters(OpBuilder &builder, Location loc, Value valueToTile,
/// number of values in `ivs`.
///
/// Some of the `valuesToTile` won't be affected by tiling. For these values,
/// llvm::None will be returned.
/// std::nullopt will be returned.
SmallVector<Optional<SliceParameters>>
computeAllSliceParameters(OpBuilder &builder, Location loc, LinalgOp linalgOp,
ValueRange valuesToTile, ArrayRef<OpFoldResult> ivs,

View File

@ -71,7 +71,7 @@ public:
Optional<StorageClass> storage = std::nullopt);
/// Returns the size in bytes for each type. If no size can be calculated,
/// returns `llvm::None`. Note that if the type has explicit layout, it is
/// returns `std::nullopt`. Note that if the type has explicit layout, it is
/// also taken into account in calculation.
Optional<int64_t> getSizeInBytes();
};

View File

@ -113,7 +113,8 @@ struct UnrollVectorOptions {
using NativeShapeFnType =
std::function<Optional<SmallVector<int64_t>>(Operation *op)>;
/// Function that returns the shape of the vector to unroll to for a given
/// operation. The unrolling is aborted if the function returns `llvm::None`.
/// operation. The unrolling is aborted if the function returns
/// `std::nullopt`.
NativeShapeFnType nativeShape = nullptr;
UnrollVectorOptions &setNativeShapeFn(NativeShapeFnType fn) {
nativeShape = std::move(fn);

View File

@ -167,8 +167,8 @@ public:
unsigned getDimPosition(unsigned idx) const;
/// Extracts the first result position where `input` dimension resides.
/// Returns `llvm::None` if `input` is not a dimension expression or cannot be
/// found in results.
/// Returns `std::nullopt` if `input` is not a dimension expression or cannot
/// be found in results.
Optional<unsigned> getResultPosition(AffineExpr input) const;
/// Return true if any affine expression involves AffineDimExpr `position`.

View File

@ -71,7 +71,7 @@ public:
///
/// * Optional<BaseT>(T)
/// - This either returns a valid Attribute/Type in the case of success,
/// nullptr in the case of failure, or `llvm::None` to signify that
/// nullptr in the case of failure, or `std::nullopt` to signify that
/// additional replacement functions may be applied (i.e. this function
/// doesn't handle that instance).
///

View File

@ -126,8 +126,8 @@ private:
namespace detail {
/// Return the `BlockArgument` corresponding to operand `operandIndex` in some
/// successor if `operandIndex` is within the range of `operands`, or None if
/// `operandIndex` isn't a successor operand index.
/// successor if `operandIndex` is within the range of `operands`, or
/// std::nullopt if `operandIndex` isn't a successor operand index.
Optional<BlockArgument>
getBranchSuccessorArgument(const SuccessorOperands &operands,
unsigned operandIndex, Block *successor);
@ -237,9 +237,9 @@ bool isRegionReturnLike(Operation *operation);
/// Returns the mutable operands that are passed to the region with the given
/// `regionIndex`. If the operation does not implement the
/// `RegionBranchTerminatorOpInterface` and is not marked as `ReturnLike`, the
/// result will be `llvm::None`. In all other cases, the resulting
/// result will be `std::nullopt`. In all other cases, the resulting
/// `OperandRange` represents all operands that are passed to the specified
/// successor region. If `regionIndex` is `llvm::None`, all operands that are
/// successor region. If `regionIndex` is `std::nullopt`, all operands that are
/// passed to the parent operation will be returned.
Optional<MutableOperandRange>
getMutableRegionBranchSuccessorOperands(Operation *operation,

View File

@ -104,7 +104,7 @@ class EffectOpInterfaceBase<string name, string baseEffect>
}
/// Return the effect of the given type `Effect` that is applied to the
/// given value, or None if no effect exists.
/// given value, or std::nullopt if no effect exists.
template <typename Effect>
::llvm::Optional<::mlir::SideEffects::EffectInstance<}] # baseEffect # [{>>
getEffectOnValue(::mlir::Value value) {

View File

@ -80,8 +80,8 @@ public:
/// Return an empty string if one does not exist.
virtual StringRef getDescription() const { return ""; }
/// Returns the name of the operation that this pass operates on, or None if
/// this is a generic OperationPass.
/// Returns the name of the operation that this pass operates on, or
/// std::nullopt if this is a generic OperationPass.
Optional<StringRef> getOpName() const { return opName; }
//===--------------------------------------------------------------------===//
@ -300,8 +300,8 @@ private:
/// Represents a unique identifier for the pass.
TypeID passID;
/// The name of the operation that this pass operates on, or None if this is a
/// generic OperationPass.
/// The name of the operation that this pass operates on, or std::nullopt if
/// this is a generic OperationPass.
Optional<StringRef> opName;
/// The current execution state for the pass.

View File

@ -41,16 +41,16 @@ public:
virtual ~PassInstrumentation() = 0;
/// A callback to run before a pass pipeline is executed. This function takes
/// the name of the operation type being operated on, or None if the pipeline
/// is op-agnostic, and information related to the parent that spawned this
/// pipeline.
/// the name of the operation type being operated on, or std::nullopt if the
/// pipeline is op-agnostic, and information related to the parent that
/// spawned this pipeline.
virtual void runBeforePipeline(Optional<OperationName> name,
const PipelineParentInfo &parentInfo);
/// A callback to run after a pass pipeline has executed. This function takes
/// the name of the operation type being operated on, or None if the pipeline
/// is op-agnostic, and information related to the parent that spawned this
/// pipeline.
/// the name of the operation type being operated on, or std::nullopt if the
/// pipeline is op-agnostic, and information related to the parent that
/// spawned this pipeline.
virtual void runAfterPipeline(Optional<OperationName> name,
const PipelineParentInfo &parentInfo);

View File

@ -125,12 +125,12 @@ public:
/// Returns the number of passes held by this manager.
size_t size() const;
/// Return the operation name that this pass manager operates on, or None if
/// this is an op-agnostic pass manager.
/// Return the operation name that this pass manager operates on, or
/// std::nullopt if this is an op-agnostic pass manager.
Optional<OperationName> getOpName(MLIRContext &context) const;
/// Return the operation name that this pass manager operates on, or None if
/// this is an op-agnostic pass manager.
/// Return the operation name that this pass manager operates on, or
/// std::nullopt if this is an op-agnostic pass manager.
Optional<StringRef> getOpName() const;
/// Return the name used to anchor this pass manager. This is either the name

View File

@ -136,7 +136,7 @@ protected:
//
// See the corresponding functions in `Timer` for additional details.
/// Return the root timer. Implementations should return `llvm::None` if the
/// Return the root timer. Implementations should return `std::nullopt` if the
/// collection of timing samples is disabled. This will cause the timers
/// constructed from the manager to be tombstones which can be skipped
/// quickly.

View File

@ -252,8 +252,8 @@ class AttrDef : public AttrOrTypeDef {
public:
using AttrOrTypeDef::AttrOrTypeDef;
/// Returns the attributes value type builder code block, or None if it
/// doesn't have one.
/// Returns the attributes value type builder code block, or std::nullopt if
/// it doesn't have one.
Optional<StringRef> getTypeBuilder() const;
static bool classof(const AttrOrTypeDef *def);

View File

@ -79,7 +79,8 @@ protected:
const llvm::Record *def;
private:
/// Return the name of the base def if there is one, or None otherwise.
/// Return the name of the base def if there is one, or std::nullopt
/// otherwise.
Optional<StringRef> getBaseDefName() const;
// What kind of constraint this is.

View File

@ -282,7 +282,7 @@ public:
enum class Kind : uint8_t { Attr, Operand, Result, Value, MultipleValues };
// Creates a SymbolInfo instance. `dagAndConstant` is only used for `Attr`
// and `Operand` so should be llvm::None for `Result` and `Value` kind.
// and `Operand` so should be std::nullopt for `Result` and `Value` kind.
SymbolInfo(const Operator *op, Kind kind,
Optional<DagAndConstant> dagAndConstant);

View File

@ -508,7 +508,7 @@ public:
ArrayRef<Expr *> resultTypes,
ArrayRef<NamedAttributeDecl *> attributes);
/// Return the name of the operation, or None if there isn't one.
/// Return the name of the operation, or std::nullopt if there isn't one.
Optional<StringRef> getName() const;
/// Return the declaration of the operation name.
@ -764,7 +764,7 @@ public:
static OpConstraintDecl *create(Context &ctx, SMRange loc,
const OpNameDecl *nameDecl = nullptr);
/// Return the name of the operation, or None if there isn't one.
/// Return the name of the operation, or std::nullopt if there isn't one.
Optional<StringRef> getName() const;
/// Return the declaration of the operation name.
@ -1028,7 +1028,7 @@ public:
bool hasBoundedRecursion,
const CompoundStmt *body);
/// Return the benefit of this pattern if specified, or None.
/// Return the benefit of this pattern if specified, or std::nullopt.
Optional<uint16_t> getBenefit() const { return benefit; }
/// Return if this pattern has bounded rewrite recursion.

View File

@ -164,7 +164,8 @@ public:
Optional<StringRef> name = std::nullopt,
const ods::Operation *odsOp = nullptr);
/// Return the name of this operation type, or None if it doesn't have on.
/// Return the name of this operation type, or std::nullopt if it doesn't have
/// on.
Optional<StringRef> getName() const;
/// Return the ODS operation that this type refers to, or nullptr if the ODS

View File

@ -91,15 +91,15 @@ public:
/// to any of the following forms(where `T` is a class derived from `Type`:
/// * Optional<Type>(T)
/// - This form represents a 1-1 type conversion. It should return nullptr
/// or `llvm::None` to signify failure. If `llvm::None` is returned, the
/// converter is allowed to try another conversion function to perform
/// the conversion.
/// or `std::nullopt` to signify failure. If `std::nullopt` is returned,
/// the converter is allowed to try another conversion function to
/// perform the conversion.
/// * Optional<LogicalResult>(T, SmallVectorImpl<Type> &)
/// - This form represents a 1-N type conversion. It should return
/// `failure` or `llvm::None` to signify a failed conversion. If the new
/// set of types is empty, the type is removed and any usages of the
/// `failure` or `std::nullopt` to signify a failed conversion. If the
/// new set of types is empty, the type is removed and any usages of the
/// existing value are expected to be removed during conversion. If
/// `llvm::None` is returned, the converter is allowed to try another
/// `std::nullopt` is returned, the converter is allowed to try another
/// conversion function to perform the conversion.
/// * Optional<LogicalResult>(T, SmallVectorImpl<Type> &, ArrayRef<Type>)
/// - This form represents a 1-N type conversion supporting recursive
@ -123,7 +123,7 @@ public:
/// where `T` is any subclass of `Type`. This function is responsible for
/// creating an operation, using the OpBuilder and Location provided, that
/// "casts" a range of values into a single value of the given type `T`. It
/// must return a Value of the converted type on success, an `llvm::None` if
/// must return a Value of the converted type on success, an `std::nullopt` if
/// it failed but other materialization can be attempted, and `nullptr` on
/// unrecoverable failure. It will only be called for (sub)types of `T`.
/// Materialization functions must be provided when a type conversion may
@ -834,8 +834,9 @@ public:
/// If the given operation instance is legal on this target, a structure
/// containing legality information is returned. If the operation is not
/// legal, std::nullopt is returned. Also returns None is operation legality
/// wasn't registered by user or dynamic legality callbacks returned None.
/// legal, std::nullopt is returned. Also returns std::nullopt if operation
/// legality wasn't registered by user or dynamic legality callbacks returned
/// None.
///
/// Note: Legality is actually a 4-state: Legal(recursive=true),
/// Legal(recursive=false), Illegal or Unknown, where Unknown is treated

View File

@ -39,10 +39,10 @@ static void collectUnderlyingAddressValues(RegionBranchOpInterface branch,
unsigned maxDepth,
DenseSet<Value> &visited,
SmallVectorImpl<Value> &output) {
// Given the index of a region of the branch (`predIndex`), or None to
// Given the index of a region of the branch (`predIndex`), or std::nullopt to
// represent the parent operation, try to return the index into the outputs of
// this region predecessor that correspond to the input values of `region`. If
// an index could not be found, None is returned instead.
// an index could not be found, std::nullopt is returned instead.
auto getOperandIndexIfPred =
[&](Optional<unsigned> predIndex) -> Optional<unsigned> {
SmallVector<RegionSuccessor, 2> successors;

View File

@ -1338,7 +1338,7 @@ MaybeOptimum<Fraction> Simplex::computeRowOptimum(Direction direction,
}
/// Compute the optimum of the specified expression in the specified direction,
/// or None if it is unbounded.
/// or std::nullopt if it is unbounded.
MaybeOptimum<Fraction> Simplex::computeOptimum(Direction direction,
ArrayRef<MPInt> coeffs) {
if (empty)

View File

@ -124,8 +124,8 @@ std::string Token::getStringValue() const {
return result;
}
/// Given a token containing a hex string literal, return its value or None if
/// the token does not contain a valid hex string.
/// Given a token containing a hex string literal, return its value or
/// std::nullopt if the token does not contain a valid hex string.
Optional<std::string> Token::getHexStringValue() const {
assert(getKind() == string);

View File

@ -91,9 +91,9 @@ public:
/// For an inttype token, return its bitwidth.
Optional<unsigned> getIntTypeBitwidth() const;
/// For an inttype token, return its signedness semantics: llvm::None means no
/// signedness semantics; true means signed integer type; false means unsigned
/// integer type.
/// For an inttype token, return its signedness semantics: std::nullopt means
/// no signedness semantics; true means signed integer type; false means
/// unsigned integer type.
Optional<bool> getIntTypeSignedness() const;
/// Given a hash_identifier token like #123, try to parse the number out of
@ -105,9 +105,10 @@ public:
/// removing the quote characters and unescaping the contents of the string.
std::string getStringValue() const;
/// Given a token containing a hex string literal, return its value or None if
/// the token does not contain a valid hex string. A hex string literal is a
/// string starting with `0x` and only containing hex digits.
/// Given a token containing a hex string literal, return its value or
/// std::nullopt if the token does not contain a valid hex string. A hex
/// string literal is a string starting with `0x` and only containing hex
/// digits.
Optional<std::string> getHexStringValue() const;
/// Given a token containing a symbol reference, return the unescaped string

View File

@ -451,7 +451,8 @@ struct BytecodeOperationName {
BytecodeOperationName(BytecodeDialect *dialect, StringRef name)
: dialect(dialect), name(name) {}
/// The loaded operation name, or None if it hasn't been processed yet.
/// The loaded operation name, or std::nullopt if it hasn't been processed
/// yet.
Optional<OperationName> opName;
/// The dialect that owns this operation name.

View File

@ -179,7 +179,7 @@ static bool isConstantOne(Value value) {
// mapping a loop nest of depth "numLoops" rooted at "forOp" to a GPU kernel.
// This may fail if the IR for computing loop bounds cannot be constructed, for
// example if an affine loop uses semi-affine maps. Return the last loop to be
// mapped on success, llvm::None on failure.
// mapped on success, std::nullopt on failure.
Optional<AffineForOp>
AffineLoopToGpuConverter::collectBounds(AffineForOp forOp, unsigned numLoops) {
OpBuilder builder(forOp.getOperation());

View File

@ -184,7 +184,7 @@ static bool broadcastSupportsMMAMatrixType(vector::BroadcastOp broadcastOp) {
}
/// Return the MMA elementwise enum associated with `op` if it is supported.
/// Return `llvm::None` otherwise.
/// Return `std::nullopt` otherwise.
static std::optional<gpu::MMAElementwiseOp>
convertElementwiseOpToMMA(Operation *op) {
if (isa<arith::AddFOp>(op))

View File

@ -146,7 +146,7 @@ void ComputationSliceState::dump() const {
/// each slice dimension maps to an existing dst dimension and both the src
/// and the dst loops for those dimensions have the same bounds. Returns false
/// if both the src and the dst loops don't have the same bounds. Returns
/// llvm::None if none of the above can be proven.
/// std::nullopt if none of the above can be proven.
Optional<bool> ComputationSliceState::isSliceMaximalFastCheck() const {
assert(lbs.size() == ubs.size() && !lbs.empty() && !ivs.empty() &&
"Unexpected number of lbs, ubs and ivs in slice");

View File

@ -960,9 +960,9 @@ private:
//===---------------------------------------------------------------------===//
/// For a given list of indices in the range of the `indexingMap` that are
/// folded, return the indices of the corresponding domain. Return `llvm::None`
/// on failure. Ensures that all the elements of the returned reassociation are
/// distinct.
/// folded, return the indices of the corresponding domain. Return
/// `std::nullopt` on failure. Ensures that all the elements of the returned
/// reassociation are distinct.
static ReassociationIndices
getDomainReassociation(AffineMap indexingMap,
ReassociationIndicesRef rangeReassociation) {

View File

@ -190,7 +190,7 @@ static SmallVector<int64_t> getReductionIndex(AffineMap map,
}
/// Look for a given dimension in an affine map and return its position. Return
/// llvm::None if the dimension is not in the map results.
/// std::nullopt if the dimension is not in the map results.
static llvm::Optional<unsigned> getDimPosition(AffineMap map, unsigned dim) {
for (unsigned i = 0, e = map.getNumResults(); i < e; i++) {
if (map.getDimPosition(i) == dim)

View File

@ -529,7 +529,8 @@ private:
return alias < rhs.alias;
}
/// The alias for the attribute or type, or None if the value has no alias.
/// The alias for the attribute or type, or std::nullopt if the value has no
/// alias.
Optional<StringRef> alias;
/// The alias depth of this attribute or type, i.e. an indication of the
/// relative ordering of when to print this alias.

View File

@ -34,8 +34,8 @@ SuccessorOperands::SuccessorOperands(unsigned int producedOperandCount,
//===----------------------------------------------------------------------===//
/// Returns the `BlockArgument` corresponding to operand `operandIndex` in some
/// successor if 'operandIndex' is within the range of 'operands', or None if
/// `operandIndex` isn't a successor operand index.
/// successor if 'operandIndex' is within the range of 'operands', or
/// std::nullopt if `operandIndex` isn't a successor operand index.
Optional<BlockArgument>
detail::getBranchSuccessorArgument(const SuccessorOperands &operands,
unsigned operandIndex, Block *successor) {
@ -85,9 +85,9 @@ detail::verifyBranchSuccessorOperands(Operation *op, unsigned succNo,
//===----------------------------------------------------------------------===//
/// Verify that types match along all region control flow edges originating from
/// `sourceNo` (region # if source is a region, llvm::None if source is parent
/// `sourceNo` (region # if source is a region, std::nullopt if source is parent
/// op). `getInputsTypesForRegion` is a function that returns the types of the
/// inputs that flow from `sourceIndex' to the given region, or llvm::None if
/// inputs that flow from `sourceIndex' to the given region, or std::nullopt if
/// the exact type match verification is not necessary (e.g., if the Op verifies
/// the match itself).
static LogicalResult
@ -363,9 +363,9 @@ bool mlir::isRegionReturnLike(Operation *operation) {
/// Returns the mutable operands that are passed to the region with the given
/// `regionIndex`. If the operation does not implement the
/// `RegionBranchTerminatorOpInterface` and is not marked as `ReturnLike`, the
/// result will be `llvm::None`. In all other cases, the resulting
/// result will be `std::nullopt`. In all other cases, the resulting
/// `OperandRange` represents all operands that are passed to the specified
/// successor region. If `regionIndex` is `llvm::None`, all operands that are
/// successor region. If `regionIndex` is `std::nullopt`, all operands that are
/// passed to the parent operation will be returned.
Optional<MutableOperandRange>
mlir::getMutableRegionBranchSuccessorOperands(Operation *operation,

View File

@ -41,10 +41,10 @@ static Optional<lsp::Location> getLocationFromLoc(StringRef uriScheme,
return lsp::Location{*sourceURI, lsp::Range(position)};
}
/// Returns a language server location from the given MLIR location, or None if
/// one couldn't be created. `uriScheme` is the scheme to use when building new
/// uris. `uri` is an optional additional filter that, when present, is used to
/// filter sub locations that do not share the same uri.
/// Returns a language server location from the given MLIR location, or
/// std::nullopt if one couldn't be created. `uriScheme` is the scheme to use
/// when building new uris. `uri` is an optional additional filter that, when
/// present, is used to filter sub locations that do not share the same uri.
static Optional<lsp::Location>
getLocationFromLoc(llvm::SourceMgr &sourceMgr, Location loc,
StringRef uriScheme, const lsp::URIForFile *uri = nullptr) {
@ -126,7 +126,7 @@ static bool isDefOrUse(const AsmParserState::SMDefinition &def, SMLoc loc,
}
/// Given a location pointing to a result, return the result number it refers
/// to or None if it refers to all of the results.
/// to or std::nullopt if it refers to all of the results.
static Optional<unsigned> getResultNumberFromLoc(SMLoc loc) {
// Skip all of the identifier characters.
auto isIdentifierChar = [](char c) {

View File

@ -46,8 +46,8 @@ public:
std::vector<Diagnostic> &diagnostics);
/// Remove the document with the given uri. Returns the version of the removed
/// document, or None if the uri did not have a corresponding document within
/// the server.
/// document, or std::nullopt if the uri did not have a corresponding document
/// within the server.
Optional<int64_t> removeDocument(const URIForFile &uri);
/// Return the locations of the object pointed at by the given position.
@ -58,8 +58,8 @@ public:
void findReferencesOf(const URIForFile &uri, const Position &pos,
std::vector<Location> &references);
/// Find a hover description for the given hover position, or None if one
/// couldn't be found.
/// Find a hover description for the given hover position, or std::nullopt if
/// one couldn't be found.
Optional<Hover> findHover(const URIForFile &uri, const Position &hoverPos);
/// Find all of the document symbols within the given file.

View File

@ -65,8 +65,8 @@ public:
int64_t version, std::vector<Diagnostic> &diagnostics);
/// Remove the document with the given uri. Returns the version of the removed
/// document, or None if the uri did not have a corresponding document within
/// the server.
/// document, or std::nullopt if the uri did not have a corresponding document
/// within the server.
Optional<int64_t> removeDocument(const URIForFile &uri);
/// Return the locations of the object pointed at by the given position.
@ -81,8 +81,8 @@ public:
void getDocumentLinks(const URIForFile &uri,
std::vector<DocumentLink> &documentLinks);
/// Find a hover description for the given hover position, or None if one
/// couldn't be found.
/// Find a hover description for the given hover position, or std::nullopt if
/// one couldn't be found.
Optional<Hover> findHover(const URIForFile &uri, const Position &hoverPos);
/// Find all of the document symbols within the given file.
@ -101,8 +101,8 @@ public:
void getInlayHints(const URIForFile &uri, const Range &range,
std::vector<InlayHint> &inlayHints);
/// Get the output of the given PDLL file, or None if there is no valid
/// output.
/// Get the output of the given PDLL file, or std::nullopt if there is no
/// valid output.
Optional<PDLLViewOutputResult> getPDLLViewOutput(const URIForFile &uri,
PDLLViewOutputKind kind);

View File

@ -57,8 +57,8 @@ public:
int64_t version, std::vector<Diagnostic> &diagnostics);
/// Remove the document with the given uri. Returns the version of the removed
/// document, or None if the uri did not have a corresponding document within
/// the server.
/// document, or std::nullopt if the uri did not have a corresponding document
/// within the server.
Optional<int64_t> removeDocument(const URIForFile &uri);
/// Return the locations of the object pointed at by the given position.
@ -73,8 +73,8 @@ public:
void getDocumentLinks(const URIForFile &uri,
std::vector<DocumentLink> &documentLinks);
/// Find a hover description for the given hover position, or None if one
/// couldn't be found.
/// Find a hover description for the given hover position, or std::nullopt if
/// one couldn't be found.
Optional<Hover> findHover(const URIForFile &uri, const Position &hoverPos);
private:

View File

@ -57,8 +57,8 @@ struct AttributeVariable
: public OpVariableElement<NamedAttribute, VariableElement::Attribute> {
using Base::Base;
/// Return the constant builder call for the type of this attribute, or None
/// if it doesn't have one.
/// Return the constant builder call for the type of this attribute, or
/// std::nullopt if it doesn't have one.
llvm::Optional<StringRef> getTypeBuilder() const {
llvm::Optional<Type> attrType = var->attr.getValueType();
return attrType ? attrType->getBuilderCall() : std::nullopt;
@ -251,7 +251,7 @@ struct OperationFormat {
public:
TypeResolution() = default;
/// Get the index into the buildable types for this type, or None.
/// Get the index into the buildable types for this type, or std::nullopt.
Optional<int> getBuilderIdx() const { return builderIdx; }
void setBuilderIdx(int idx) { builderIdx = idx; }
@ -263,7 +263,7 @@ struct OperationFormat {
const NamedAttribute *getAttribute() const {
return resolver.dyn_cast<const NamedAttribute *>();
}
/// Get the transformer for the type of the variable, or None.
/// Get the transformer for the type of the variable, or std::nullopt.
Optional<StringRef> getVarTransformer() const {
return variableTransformer;
}

View File

@ -71,7 +71,7 @@ class {0}(_ods_ir.OpView):
/// Each segment spec is either None (default) or an array of integers
/// where:
/// 1 = single element (expect non sequence operand/result)
/// 0 = optional element (expect a value or None)
/// 0 = optional element (expect a value or std::nullopt)
/// -1 = operand/result is a sequence corresponding to a variadic
constexpr const char *opClassSizedSegmentsTemplate = R"Py(
_ODS_{0}_SEGMENTS = {1}