From 192d9dd731921a377bc538fc2b13871815fac87d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 4 Dec 2022 19:58:32 -0800 Subject: [PATCH] [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 --- mlir/docs/DialectConversion.md | 8 ++++---- .../mlir/Analysis/Presburger/Simplex.h | 2 +- .../mlir/Dialect/Affine/Analysis/Utils.h | 2 +- .../IR/BufferizableOpInterface.h | 2 +- .../Linalg/Analysis/DependenceAnalysis.h | 6 +++--- .../Dialect/Linalg/Transforms/Transforms.h | 2 +- .../include/mlir/Dialect/Linalg/Utils/Utils.h | 4 ++-- .../mlir/Dialect/SPIRV/IR/SPIRVTypes.h | 2 +- .../Vector/Transforms/VectorRewritePatterns.h | 3 ++- mlir/include/mlir/IR/AffineMap.h | 4 ++-- mlir/include/mlir/IR/SubElementInterfaces.h | 2 +- .../mlir/Interfaces/ControlFlowInterfaces.h | 8 ++++---- .../Interfaces/SideEffectInterfaceBase.td | 2 +- mlir/include/mlir/Pass/Pass.h | 8 ++++---- mlir/include/mlir/Pass/PassInstrumentation.h | 12 ++++++------ mlir/include/mlir/Pass/PassManager.h | 8 ++++---- mlir/include/mlir/Support/Timing.h | 2 +- mlir/include/mlir/TableGen/AttrOrTypeDef.h | 4 ++-- mlir/include/mlir/TableGen/Constraint.h | 3 ++- mlir/include/mlir/TableGen/Pattern.h | 2 +- mlir/include/mlir/Tools/PDLL/AST/Nodes.h | 6 +++--- mlir/include/mlir/Tools/PDLL/AST/Types.h | 3 ++- .../mlir/Transforms/DialectConversion.h | 19 ++++++++++--------- .../AliasAnalysis/LocalAliasAnalysis.cpp | 4 ++-- mlir/lib/Analysis/Presburger/Simplex.cpp | 2 +- mlir/lib/AsmParser/Token.cpp | 4 ++-- mlir/lib/AsmParser/Token.h | 13 +++++++------ mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 3 ++- mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp | 2 +- .../Conversion/VectorToGPU/VectorToGPU.cpp | 2 +- mlir/lib/Dialect/Affine/Analysis/Utils.cpp | 2 +- .../Linalg/Transforms/ElementwiseOpFusion.cpp | 6 +++--- .../Vector/Transforms/VectorTransforms.cpp | 2 +- mlir/lib/IR/AsmPrinter.cpp | 3 ++- mlir/lib/Interfaces/ControlFlowInterfaces.cpp | 12 ++++++------ mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp | 10 +++++----- mlir/lib/Tools/mlir-lsp-server/MLIRServer.h | 8 ++++---- .../Tools/mlir-pdll-lsp-server/PDLLServer.h | 12 ++++++------ .../Tools/tblgen-lsp-server/TableGenServer.h | 8 ++++---- mlir/tools/mlir-tblgen/OpFormatGen.cpp | 8 ++++---- mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp | 2 +- 41 files changed, 112 insertions(+), 105 deletions(-) diff --git a/mlir/docs/DialectConversion.md b/mlir/docs/DialectConversion.md index 3de7a897a3b8..9485064375b5 100644 --- a/mlir/docs/DialectConversion.md +++ b/mlir/docs/DialectConversion.md @@ -301,15 +301,15 @@ class TypeConverter { /// to any of the following forms(where `T` is a class derived from `Type`: /// * Optional(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(T, SmallVectorImpl &) /// - 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(T, SmallVectorImpl &, ArrayRef) /// - 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`. /// diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h index 34b77a029af0..bcbec8ce5a81 100644 --- a/mlir/include/mlir/Analysis/Presburger/Simplex.h +++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h @@ -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> findIntegerSample(); diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h index b75cabb70b36..961827d1f171 100644 --- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h +++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h @@ -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 isSliceMaximalFastCheck() const; }; diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h index b3bdb4360363..78f73870a6ba 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h @@ -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 defaultMemorySpace = Attribute(); diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index ff043dbc1408..b65db9fbf67d 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -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 getResultNumber(OpView opView) { if (OpResult result = opView.dyn_cast().cast()) 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 getDependentOpViewOperandNum() const { return getOperandNumber(dependentOpView); } // If the indexing OpView is an operand, return operand number. Return - // llvm::None otherwise. + // std::nullopt otherwise. Optional getIndexingOpViewOperandNum() const { return getOperandNumber(indexingOpView); } diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h index 7c48782f0492..f8473151c009 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -184,7 +184,7 @@ std::pair 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 diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 4f9dd71857f9..3152061e6cbc 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -138,7 +138,7 @@ Optional> getReassociationMapForFoldingUnitDims(ArrayRef 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 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> computeAllSliceParameters(OpBuilder &builder, Location loc, LinalgOp linalgOp, ValueRange valuesToTile, ArrayRef ivs, diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h index 6218b62f075b..33a0f577f9ca 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h @@ -71,7 +71,7 @@ public: Optional 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 getSizeInBytes(); }; diff --git a/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h b/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h index 0ab03085f5ae..e4606f9b428f 100644 --- a/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h +++ b/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h @@ -113,7 +113,8 @@ struct UnrollVectorOptions { using NativeShapeFnType = std::function>(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); diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index 74cc3b1eb17a..3f484ba63e80 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -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 getResultPosition(AffineExpr input) const; /// Return true if any affine expression involves AffineDimExpr `position`. diff --git a/mlir/include/mlir/IR/SubElementInterfaces.h b/mlir/include/mlir/IR/SubElementInterfaces.h index 9b14b1790ee5..e284c043a8c1 100644 --- a/mlir/include/mlir/IR/SubElementInterfaces.h +++ b/mlir/include/mlir/IR/SubElementInterfaces.h @@ -71,7 +71,7 @@ public: /// /// * Optional(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). /// diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h index 416fcc354cdb..b39058620196 100644 --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h @@ -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 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 getMutableRegionBranchSuccessorOperands(Operation *operation, diff --git a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td index 842b7ff6d50b..e821c9e03abd 100644 --- a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td +++ b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td @@ -104,7 +104,7 @@ class EffectOpInterfaceBase } /// 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 ::llvm::Optional<::mlir::SideEffects::EffectInstance<}] # baseEffect # [{>> getEffectOnValue(::mlir::Value value) { diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 5953e9d02493..aa22fce5c039 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -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 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 opName; /// The current execution state for the pass. diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index a99cafbf2686..8cb6b708ec7a 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -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 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 name, const PipelineParentInfo &parentInfo); diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index 058e2d738b38..d7c354ec6fb9 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -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 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 getOpName() const; /// Return the name used to anchor this pass manager. This is either the name diff --git a/mlir/include/mlir/Support/Timing.h b/mlir/include/mlir/Support/Timing.h index 180559c91243..f9d877e07079 100644 --- a/mlir/include/mlir/Support/Timing.h +++ b/mlir/include/mlir/Support/Timing.h @@ -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. diff --git a/mlir/include/mlir/TableGen/AttrOrTypeDef.h b/mlir/include/mlir/TableGen/AttrOrTypeDef.h index 1abaf64b878e..6a03e3426152 100644 --- a/mlir/include/mlir/TableGen/AttrOrTypeDef.h +++ b/mlir/include/mlir/TableGen/AttrOrTypeDef.h @@ -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 getTypeBuilder() const; static bool classof(const AttrOrTypeDef *def); diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h index c0765739016e..92999be9cf58 100644 --- a/mlir/include/mlir/TableGen/Constraint.h +++ b/mlir/include/mlir/TableGen/Constraint.h @@ -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 getBaseDefName() const; // What kind of constraint this is. diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index bdd01ed8a367..8f6cdf762363 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -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); diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h index 6e6d6160ab33..af8a05e072d6 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -508,7 +508,7 @@ public: ArrayRef resultTypes, ArrayRef 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 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 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 getBenefit() const { return benefit; } /// Return if this pattern has bounded rewrite recursion. diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h index d51f3290e638..22cdf8333f98 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -164,7 +164,8 @@ public: Optional 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 getName() const; /// Return the ODS operation that this type refers to, or nullptr if the ODS diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 307b126c2306..11a53206c209 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -91,15 +91,15 @@ public: /// to any of the following forms(where `T` is a class derived from `Type`: /// * Optional(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(T, SmallVectorImpl &) /// - 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(T, SmallVectorImpl &, ArrayRef) /// - 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 diff --git a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp index caefd1c77962..0c9beeaaf301 100644 --- a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp +++ b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp @@ -39,10 +39,10 @@ static void collectUnderlyingAddressValues(RegionBranchOpInterface branch, unsigned maxDepth, DenseSet &visited, SmallVectorImpl &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 predIndex) -> Optional { SmallVector successors; diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp index 98ea8653c135..5c9d42019e8a 100644 --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -1338,7 +1338,7 @@ MaybeOptimum 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 Simplex::computeOptimum(Direction direction, ArrayRef coeffs) { if (empty) diff --git a/mlir/lib/AsmParser/Token.cpp b/mlir/lib/AsmParser/Token.cpp index 7000c1419e60..120a810ee6e5 100644 --- a/mlir/lib/AsmParser/Token.cpp +++ b/mlir/lib/AsmParser/Token.cpp @@ -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 Token::getHexStringValue() const { assert(getKind() == string); diff --git a/mlir/lib/AsmParser/Token.h b/mlir/lib/AsmParser/Token.h index 9f5cf1f83788..5f712b893793 100644 --- a/mlir/lib/AsmParser/Token.h +++ b/mlir/lib/AsmParser/Token.h @@ -91,9 +91,9 @@ public: /// For an inttype token, return its bitwidth. Optional 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 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 getHexStringValue() const; /// Given a token containing a symbol reference, return the unescaped string diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp index 4ea8759615fc..8c08ca7bb7d1 100644 --- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp +++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp @@ -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 opName; /// The dialect that owns this operation name. diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp index e06da8030539..6be4a356e967 100644 --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -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 AffineLoopToGpuConverter::collectBounds(AffineForOp forOp, unsigned numLoops) { OpBuilder builder(forOp.getOperation()); diff --git a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp index 416a193ffc93..c168765458b5 100644 --- a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp +++ b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp @@ -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 convertElementwiseOpToMMA(Operation *op) { if (isa(op)) diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp index ca78601af303..33c0f207a189 100644 --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -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 ComputationSliceState::isSliceMaximalFastCheck() const { assert(lbs.size() == ubs.size() && !lbs.empty() && !ivs.empty() && "Unexpected number of lbs, ubs and ivs in slice"); diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp index 43d01205dfad..7039c71faddb 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @@ -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) { diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp index 592697d1e58e..fda709303b99 100644 --- a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp @@ -190,7 +190,7 @@ static SmallVector 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 getDimPosition(AffineMap map, unsigned dim) { for (unsigned i = 0, e = map.getNumResults(); i < e; i++) { if (map.getDimPosition(i) == dim) diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 8f9ec2476663..3f7442d4e306 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -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 alias; /// The alias depth of this attribute or type, i.e. an indication of the /// relative ordering of when to print this alias. diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp index 77b57bc4a892..e87724eee796 100644 --- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp +++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp @@ -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 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 mlir::getMutableRegionBranchSuccessorOperands(Operation *operation, diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index 150e731e99e5..f93861e06445 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -41,10 +41,10 @@ static Optional 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 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 getResultNumberFromLoc(SMLoc loc) { // Skip all of the identifier characters. auto isIdentifierChar = [](char c) { diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.h b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.h index ee6c2cd25bd5..f7978708385c 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.h +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.h @@ -46,8 +46,8 @@ public: std::vector &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 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 &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 findHover(const URIForFile &uri, const Position &hoverPos); /// Find all of the document symbols within the given file. diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.h b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.h index e6d117c6ec30..2542354d0e2c 100644 --- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.h +++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.h @@ -65,8 +65,8 @@ public: int64_t version, std::vector &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 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 &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 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 &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 getPDLLViewOutput(const URIForFile &uri, PDLLViewOutputKind kind); diff --git a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.h b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.h index 4ae73e352d48..0565c27ef6ca 100644 --- a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.h +++ b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.h @@ -57,8 +57,8 @@ public: int64_t version, std::vector &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 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 &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 findHover(const URIForFile &uri, const Position &hoverPos); private: diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index 07a6ab9c2b71..daa4e9de7053 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -57,8 +57,8 @@ struct AttributeVariable : public OpVariableElement { 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 getTypeBuilder() const { llvm::Optional 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 getBuilderIdx() const { return builderIdx; } void setBuilderIdx(int idx) { builderIdx = idx; } @@ -263,7 +263,7 @@ struct OperationFormat { const NamedAttribute *getAttribute() const { return resolver.dyn_cast(); } - /// Get the transformer for the type of the variable, or None. + /// Get the transformer for the type of the variable, or std::nullopt. Optional getVarTransformer() const { return variableTransformer; } diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp index f83908c36838..a5ffcc44519f 100644 --- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp +++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp @@ -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}