diff --git a/mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h b/mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h index dbc6c64aa623..48a82b19501c 100644 --- a/mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h +++ b/mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h @@ -26,17 +26,19 @@ using MemorySpaceToStorageClassMap = std::function(Attribute)>; /// Maps MemRef memory spaces to storage classes for Vulkan-flavored SPIR-V -/// using the default rule. Returns None if the memory space is unknown. +/// using the default rule. Returns std::nullopt if the memory space is unknown. Optional mapMemorySpaceToVulkanStorageClass(Attribute); /// Maps storage classes for Vulkan-flavored SPIR-V to MemRef memory spaces -/// using the default rule. Returns None if the storage class is unsupported. +/// using the default rule. Returns std::nullopt if the storage class is +/// unsupported. Optional mapVulkanStorageClassToMemorySpace(spirv::StorageClass); /// Maps MemRef memory spaces to storage classes for OpenCL-flavored SPIR-V -/// using the default rule. Returns None if the memory space is unknown. +/// using the default rule. Returns std::nullopt if the memory space is unknown. Optional mapMemorySpaceToOpenCLStorageClass(Attribute); /// Maps storage classes for OpenCL-flavored SPIR-V to MemRef memory spaces -/// using the default rule. Returns None if the storage class is unsupported. +/// using the default rule. Returns std::nullopt if the storage class is +/// unsupported. Optional mapOpenCLStorageClassToMemorySpace(spirv::StorageClass); /// Type converter for converting numeric MemRef memory spaces into SPIR-V diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h index 9caa589a69bf..b75cabb70b36 100644 --- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h +++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h @@ -110,7 +110,7 @@ struct ComputationSliceState { bool isEmpty() const { return ivs.empty(); } /// Returns true if the computation slice encloses all the iterations of the - /// sliced loop nest. Returns false if it does not. Returns llvm::None if it + /// sliced loop nest. Returns false if it does not. Returns std::nullopt if it /// cannot determine if the slice is maximal or not. // TODO: Cache 'isMaximal' so that we don't recompute it when the slice // information hasn't changed. diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index a82d25a4c211..ff043dbc1408 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -76,7 +76,7 @@ public: return opView.get(); } // Return the indexing map of the operand/result in `opView` specified in - // the owning LinalgOp. If the owner is not a LinalgOp returns llvm::None. + // the owning LinalgOp. If the owner is not a LinalgOp returns std::nullopt. static Optional getIndexingMap(OpView opView) { auto owner = dyn_cast(getOwner(opView)); if (!owner) @@ -87,7 +87,7 @@ public: opView.get().cast().getResultNumber())); } // Return the operand number if the `opView` is an OpOperand *. Otherwise - // return llvm::None. + // return std::nullopt. static Optional getOperandNumber(OpView opView) { if (OpOperand *operand = opView.dyn_cast()) return operand->getOperandNumber(); @@ -126,13 +126,13 @@ public: } // If the dependent OpView is a result value, return the result - // number. Return llvm::None otherwise. + // number. Return std::nullopt otherwise. Optional getDependentOpViewResultNum() const { return getResultNumber(dependentOpView); } // If the dependent OpView is a result value, return the result - // number. Return llvm::None otherwise. + // number. Return std::nullopt otherwise. Optional getIndexingOpViewResultNum() const { return getResultNumber(indexingOpView); } diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h index 6538abceb629..9932f36e5f1b 100644 --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h @@ -50,8 +50,8 @@ LogicalResult foldMemRefCast(Operation *op, Value inner = nullptr); Type getTensorTypeFromMemRefType(Type type); /// Finds a single dealloc operation for the given allocated value. If there -/// are > 1 deallocates for `allocValue`, returns None, else returns the single -/// deallocate if it exists or nullptr. +/// are > 1 deallocates for `allocValue`, returns std::nullopt, else returns the +/// single deallocate if it exists or nullptr. Optional findDealloc(Value allocValue); } // namespace memref diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td index 60f254863cb1..fbee86b0a0ce 100644 --- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td +++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td @@ -273,7 +273,7 @@ def ForOp : SCF_Op<"for", return getOperation()->getNumOperands() - getNumControlOperands(); } /// Get the iter arg number for an operand. If it isnt an iter arg - /// operand return llvm::None. + /// operand return std::nullopt. Optional getIterArgNumberForOpOperand(OpOperand &opOperand) { if (opOperand.getOwner() != getOperation()) return std::nullopt; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h index 0f5e40e06d5a..48c08cfa69b5 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h @@ -34,13 +34,13 @@ public: /// Returns true if the given capability is allowed. bool allows(Capability) const; /// Returns the first allowed one if any of the given capabilities is allowed. - /// Returns llvm::None otherwise. + /// Returns std::nullopt otherwise. Optional allows(ArrayRef) const; /// Returns true if the given extension is allowed. bool allows(Extension) const; /// Returns the first allowed one if any of the given extensions is allowed. - /// Returns llvm::None otherwise. + /// Returns std::nullopt otherwise. Optional allows(ArrayRef) const; /// Returns the vendor ID. diff --git a/mlir/include/mlir/Dialect/Utils/IndexingUtils.h b/mlir/include/mlir/Dialect/Utils/IndexingUtils.h index bc58c127e162..e9493e26d48e 100644 --- a/mlir/include/mlir/Dialect/Utils/IndexingUtils.h +++ b/mlir/include/mlir/Dialect/Utils/IndexingUtils.h @@ -44,16 +44,17 @@ SmallVector computeElementwiseMul(ArrayRef v1, /// Compute and return the multi-dimensional integral ratio of `subShape` to /// the trailing dimensions of `shape`. This represents how many times /// `subShape` fits within `shape`. -/// If integral division is not possible, return None. +/// If integral division is not possible, return std::nullopt. /// The trailing `subShape.size()` entries of both shapes are assumed (and /// enforced) to only contain noonnegative values. /// /// Examples: /// - shapeRatio({3, 5, 8}, {2, 5, 2}) returns {3, 2, 1}. -/// - shapeRatio({3, 8}, {2, 5, 2}) returns None (subshape has higher rank). +/// - shapeRatio({3, 8}, {2, 5, 2}) returns std::nullopt (subshape has higher +/// rank). /// - shapeRatio({42, 2, 10, 32}, {2, 5, 2}) returns {42, 1, 2, 16} which is /// derived as {42(leading shape dim), 2/2, 10/5, 32/2}. -/// - shapeRatio({42, 2, 11, 32}, {2, 5, 2}) returns None which is +/// - shapeRatio({42, 2, 11, 32}, {2, 5, 2}) returns std::nullopt which is /// derived as {42(leading shape dim), 2/2, 11/5(not divisible), 32/2}. Optional> computeShapeRatio(ArrayRef shape, ArrayRef subShape); diff --git a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h index bc5bbc74d8f3..0711aa3ba80d 100644 --- a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h +++ b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h @@ -64,7 +64,7 @@ SmallVector convertReassociationMapsToIndices( OpBuilder &b, ArrayRef reassociationExprs); /// Return the reassociations maps to use to reshape given the source type and -/// the target type when possible. Return llvm::None when this computation +/// the target type when possible. Return std::nullopt when this computation /// failed. Optional> getReassociationIndicesForReshape(ShapedType sourceType, ShapedType targetType); diff --git a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td index 22e91f1e1abb..72cba52ed26e 100644 --- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td +++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td @@ -393,7 +393,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> { // Failable Value Iteration /// If this attribute supports iterating over element values of type `T`, - /// return the iterable range. Otherwise, return llvm::None. + /// return the iterable range. Otherwise, return std::nullopt. template DefaultValueCheckT>> tryGetValues() const { if (Optional> beginIt = try_value_begin()) @@ -404,7 +404,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> { DefaultValueCheckT>> try_value_begin() const; /// If this attribute supports iterating over element values of type `T`, - /// return the iterable range. Otherwise, return llvm::None. + /// return the iterable range. Otherwise, return std::nullopt. template > Optional> tryGetValues() const { auto values = tryGetValues(); diff --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h index e6902fb75030..f9365ef5cd48 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.h +++ b/mlir/include/mlir/IR/BuiltinAttributes.h @@ -784,7 +784,7 @@ public: get(ShapedType type, StringRef blobName, AsmResourceBlob blob); /// Return the data of this attribute as an ArrayRef if it is present, - /// returns None otherwise. + /// returns std::nullopt otherwise. Optional> tryGetAsArrayRef() const; /// Support for isa<>/cast<>. diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index fc0f696cefc2..1a06c92e725e 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -576,7 +576,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [ static bool sortInPlace(SmallVectorImpl &array); /// Returns an entry with a duplicate name in `array`, if it exists, else - /// returns llvm::None. If `isSorted` is true, the array is assumed to be + /// returns std::nullopt. If `isSorted` is true, the array is assumed to be /// sorted else it will be sorted in place before finding the duplicate entry. static Optional findDuplicate(SmallVectorImpl &array, bool isSorted); diff --git a/mlir/include/mlir/IR/BuiltinTypes.h b/mlir/include/mlir/IR/BuiltinTypes.h index 03fc70937c2d..5aeea57c9671 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.h +++ b/mlir/include/mlir/IR/BuiltinTypes.h @@ -335,8 +335,8 @@ private: /// `reducedShape`. The returned mask can be applied as a projection to /// `originalShape` to obtain the `reducedShape`. This mask is useful to track /// which dimensions must be kept when e.g. compute MemRef strides under -/// rank-reducing operations. Return None if reducedShape cannot be obtained -/// by dropping only `1` entries in `originalShape`. +/// rank-reducing operations. Return std::nullopt if reducedShape cannot be +/// obtained by dropping only `1` entries in `originalShape`. llvm::Optional> computeRankReductionMask(ArrayRef originalShape, ArrayRef reducedShape); diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 6ac6c0b0ba65..b7945710bd70 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -50,7 +50,7 @@ public: OperationName getName() { return name; } /// If this operation has a registered operation description, return it. - /// Otherwise return None. + /// Otherwise return std::nullopt. Optional getRegisteredInfo() { return getName().getRegisteredInfo(); } diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 576a4ecc6f49..586b6cd5e3bd 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -251,7 +251,7 @@ inline llvm::hash_code hash_value(OperationName arg) { class RegisteredOperationName : public OperationName { public: /// Lookup the registered operation information for the given operation. - /// Returns None if the operation isn't registered. + /// Returns std::nullopt if the operation isn't registered. static Optional lookup(StringRef name, MLIRContext *ctx); @@ -464,8 +464,8 @@ Attribute getAttrFromSortedRange(IteratorT first, IteratorT last, NameT name) { return result.second ? result.first->getValue() : Attribute(); } -/// Get an attribute from a sorted range of named attributes. Returns None if -/// the attribute was not found. +/// Get an attribute from a sorted range of named attributes. Returns +/// std::nullopt if the attribute was not found. template Optional getNamedAttrFromSortedRange(IteratorT first, IteratorT last, NameT name) { @@ -554,7 +554,7 @@ public: void pop_back() { attrs.pop_back(); } /// Returns an entry with a duplicate name the list, if it exists, else - /// returns llvm::None. + /// returns std::nullopt. Optional findDuplicate() const; /// Return a dictionary attribute for the underlying dictionary. This will diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index e59ec8d73b7a..e548dc9e708b 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -88,7 +88,7 @@ public: ArrayRef getGeneratedOps() const { return generatedOps; } /// Return the root node that this pattern matches. Patterns that can match - /// multiple root types return None. + /// multiple root types return std::nullopt. Optional getRootKind() const { if (rootKind == RootKind::OperationName) return OperationName::getFromOpaquePointer(rootValue); @@ -97,7 +97,7 @@ public: /// Return the interface ID used to match the root operation of this pattern. /// If the pattern does not use an interface ID for deciding the root match, - /// this returns None. + /// this returns std::nullopt. Optional getRootInterfaceID() const { if (rootKind == RootKind::InterfaceID) return TypeID::getFromOpaquePointer(rootValue); @@ -106,7 +106,7 @@ public: /// Return the trait ID used to match the root operation of this pattern. /// If the pattern does not use a trait ID for deciding the root match, this - /// returns None. + /// returns std::nullopt. Optional getRootTraitID() const { if (rootKind == RootKind::TraitID) return TypeID::getFromOpaquePointer(rootValue); diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index 7e7d31cc1bdd..6addd72be1fb 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -179,15 +179,15 @@ public: /// Get an iterator range for all of the uses, for any symbol, that are nested /// within the given operation 'from'. This does not traverse into any nested - /// symbol tables. This function returns None if there are any unknown + /// symbol tables. This function returns std::nullopt if there are any unknown /// operations that may potentially be symbol tables. static Optional getSymbolUses(Operation *from); static Optional getSymbolUses(Region *from); /// Get all of the uses of the given symbol that are nested within the given /// operation 'from'. This does not traverse into any nested symbol tables. - /// This function returns None if there are any unknown operations that may - /// potentially be symbol tables. + /// This function returns std::nullopt if there are any unknown operations + /// that may potentially be symbol tables. static Optional getSymbolUses(StringAttr symbol, Operation *from); static Optional getSymbolUses(Operation *symbol, Operation *from); static Optional getSymbolUses(StringAttr symbol, Region *from); diff --git a/mlir/include/mlir/TableGen/CodeGenHelpers.h b/mlir/include/mlir/TableGen/CodeGenHelpers.h index ecde28f73138..90eff6d3551a 100644 --- a/mlir/include/mlir/TableGen/CodeGenHelpers.h +++ b/mlir/include/mlir/TableGen/CodeGenHelpers.h @@ -135,8 +135,8 @@ public: /// /// LogicalResult(Operation *op, Attribute attr, StringRef attrName); /// - /// If a uniqued constraint was not found, this function returns None. The - /// uniqued constraints cannot be used in the context of an OpAdaptor. + /// If a uniqued constraint was not found, this function returns std::nullopt. + /// The uniqued constraints cannot be used in the context of an OpAdaptor. /// /// Pattern constraints have the form: /// diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index 7cc263faa4c2..9aaacdbe62ff 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -53,7 +53,7 @@ public: bool isVariableLength() const { return isOptional() || isVariadic(); } // Returns the builder call for this constraint if this is a buildable type, - // returns None otherwise. + // returns std::nullopt otherwise. Optional getBuilderCall() const; // Return the C++ class name for this type (which may just be ::mlir::Type). diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h index 9f958c59421d..6e6d6160ab33 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -668,7 +668,7 @@ public: void setDocComment(Context &ctx, StringRef comment); /// Return the documentation comment attached to this decl if it has been set. - /// Otherwise, returns None. + /// Otherwise, returns std::nullopt. Optional getDocComment() const { return docComment; } protected: @@ -901,8 +901,8 @@ public: return const_cast(this)->getInputs(); } - /// Return the explicit native type to use for the given input. Returns None - /// if no explicit type was set. + /// Return the explicit native type to use for the given input. Returns + /// std::nullopt if no explicit type was set. Optional getNativeInputType(unsigned index) const; /// Return the explicit results of the constraint declaration. May be empty, diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 55665b56f2fe..307b126c2306 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -834,8 +834,8 @@ public: /// If the given operation instance is legal on this target, a structure /// containing legality information is returned. If the operation is not - /// legal, None 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 None is 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/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp index f08af75a6084..98ea8653c135 100644 --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -1325,7 +1325,7 @@ MaybeOptimum Simplex::computeRowOptimum(Direction direction, // Keep trying to find a pivot for the row in the specified direction. while (Optional maybePivot = findPivot(row, direction)) { // If findPivot returns a pivot involving the row itself, then the optimum - // is unbounded, so we return None. + // is unbounded, so we return std::nullopt. if (maybePivot->row == row) return OptimumKind::Unbounded; pivot(*maybePivot); @@ -1610,7 +1610,7 @@ Optional> Simplex::getSamplePointIfIntegral() const { SmallVector integerSample; integerSample.reserve(var.size()); for (const Fraction &coord : rationalSample) { - // If the sample is non-integral, return None. + // If the sample is non-integral, return std::nullopt. if (coord.num % coord.den != 0) return {}; integerSample.push_back(coord.num / coord.den); diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp index cec129ac66b7..e10dd5e108cd 100644 --- a/mlir/lib/AsmParser/AttributeParser.cpp +++ b/mlir/lib/AsmParser/AttributeParser.cpp @@ -1166,8 +1166,8 @@ Attribute Parser::parseStridedLayoutAttr() { return nullptr; // Parses either an integer token or a question mark token. Reports an error - // and returns None if the current token is neither. The integer token must - // fit into int64_t limits. + // and returns std::nullopt if the current token is neither. The integer token + // must fit into int64_t limits. auto parseStrideOrOffset = [&]() -> Optional { if (consumeIf(Token::question)) return ShapedType::kDynamic; diff --git a/mlir/lib/AsmParser/Token.cpp b/mlir/lib/AsmParser/Token.cpp index 4f465ff38405..7000c1419e60 100644 --- a/mlir/lib/AsmParser/Token.cpp +++ b/mlir/lib/AsmParser/Token.cpp @@ -24,7 +24,7 @@ SMLoc Token::getEndLoc() const { SMRange Token::getLocRange() const { return SMRange(getLoc(), getEndLoc()); } /// For an integer token, return its value as an unsigned. If it doesn't fit, -/// return None. +/// return std::nullopt. Optional Token::getUnsignedIntegerValue() const { bool isHex = spelling.size() > 1 && spelling[1] == 'x'; @@ -35,7 +35,7 @@ Optional Token::getUnsignedIntegerValue() const { } /// For an integer token, return its value as a uint64_t. If it doesn't fit, -/// return None. +/// return std::nullopt. Optional Token::getUInt64IntegerValue(StringRef spelling) { bool isHex = spelling.size() > 1 && spelling[1] == 'x'; @@ -45,8 +45,8 @@ Optional Token::getUInt64IntegerValue(StringRef spelling) { return result; } -/// For a floatliteral, return its value as a double. Return None if the value -/// underflows or overflows. +/// For a floatliteral, return its value as a double. Return std::nullopt if the +/// value underflows or overflows. Optional Token::getFloatingPointValue() const { double result = 0; if (spelling.getAsDouble(result)) diff --git a/mlir/lib/AsmParser/Token.h b/mlir/lib/AsmParser/Token.h index 0e48805bb06f..9f5cf1f83788 100644 --- a/mlir/lib/AsmParser/Token.h +++ b/mlir/lib/AsmParser/Token.h @@ -74,18 +74,18 @@ public: // Helpers to decode specific sorts of tokens. /// For an integer token, return its value as an unsigned. If it doesn't fit, - /// return None. + /// return std::nullopt. Optional getUnsignedIntegerValue() const; /// For an integer token, return its value as an uint64_t. If it doesn't fit, - /// return None. + /// return std::nullopt. static Optional getUInt64IntegerValue(StringRef spelling); Optional getUInt64IntegerValue() const { return getUInt64IntegerValue(getSpelling()); } - /// For a floatliteral token, return its value as a double. Returns None in - /// the case of underflow or overflow. + /// For a floatliteral token, return its value as a double. Returns + /// std::nullopt in the case of underflow or overflow. Optional getFloatingPointValue() const; /// For an inttype token, return its bitwidth. diff --git a/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp b/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp index cfb0e5532687..9e965e3083b2 100644 --- a/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp +++ b/mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp @@ -114,7 +114,7 @@ static bool isAllocationSupported(Operation *allocOp, MemRefType type) { /// Returns the scope to use for atomic operations use for emulating store /// operations of unsupported integer bitwidths, based on the memref -/// type. Returns None on failure. +/// type. Returns std::nullopt on failure. static Optional getAtomicOpScope(MemRefType type) { auto sc = type.getMemorySpace().dyn_cast_or_null(); switch (sc.getValue()) { diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp index b9325b3717a0..ca78601af303 100644 --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -283,7 +283,7 @@ Optional ComputationSliceState::isSliceValid() { } /// Returns true if the computation slice encloses all the iterations of the -/// sliced loop nest. Returns false if it does not. Returns llvm::None if it +/// sliced loop nest. Returns false if it does not. Returns std::nullopt if it /// cannot determine if the slice is maximal or not. Optional ComputationSliceState::isMaximal() const { // Fast check to determine if the computation slice is maximal. If the result diff --git a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp index 243c3ef50faa..586c8e6a11aa 100644 --- a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp +++ b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp @@ -17,7 +17,7 @@ using namespace mlir; using namespace mlir::arith; /// Function that evaluates the result of doing something on arithmetic -/// constants and returns None on overflow. +/// constants and returns std::nullopt on overflow. using ConstArithFn = function_ref(const APInt &, const APInt &)>; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp index 462102a4f733..7e5e608bb330 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp @@ -278,7 +278,7 @@ Optional mlir::LLVM::extractPointerSpecValue(Attribute attr, /// Returns the part of the data layout entry that corresponds to `pos` for the /// given `type` by interpreting the list of entries `params`. For the pointer /// type in the default address space, returns the default value if the entries -/// do not provide a custom one, for other address spaces returns None. +/// do not provide a custom one, for other address spaces returns std::nullopt. static Optional getPointerDataLayoutEntry(DataLayoutEntryListRef params, LLVMPointerType type, PtrDLEntryPos pos) { diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp index b5d1dfd9bb24..cb325ff17958 100644 --- a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp @@ -48,7 +48,7 @@ llvm::Optional mlir::memref::findDealloc(Value allocValue) { for (Operation *user : allocValue.getUsers()) { if (!hasEffect(user, allocValue)) continue; - // If we found > 1 dealloc, return None. + // If we found > 1 dealloc, return std::nullopt. if (dealloc) return std::nullopt; dealloc = user; diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index 97313e191fe2..a7ca5783d67d 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -719,7 +719,7 @@ struct ForOpIterArgsFolder : public OpRewritePattern { }; /// Util function that tries to compute a constant diff between u and l. -/// Returns llvm::None when the difference between two AffineValueMap is +/// Returns std::nullopt when the difference between two AffineValueMap is /// dynamic. static Optional computeConstDiff(Value l, Value u) { IntegerAttr clb, cub; diff --git a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp index 381f2316e94a..9998fcabd829 100644 --- a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp @@ -44,8 +44,8 @@ public: // // Derived classes should provide the following method which performs the - // actual conversion. It should return llvm::None upon conversion failure and - // return the converted operation upon success. + // actual conversion. It should return std::nullopt upon conversion failure + // and return the converted operation upon success. // // Optional convertSourceOp(SourceOp op, OpAdaptor adaptor, // ConversionPatternRewriter &rewriter, diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp index 7330b399cde2..520ee5f2fe64 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp @@ -82,7 +82,7 @@ static Type getRuntimeArrayElementType(Type type) { } /// Given a list of resource element `types`, returns the index of the canonical -/// resource that all resources should be unified into. Returns llvm::None if +/// resource that all resources should be unified into. Returns std::nullopt if /// unable to unify. static Optional deduceCanonicalResource(ArrayRef types) { // scalarNumBits: contains all resources' scalar types' bit counts. diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp index 52dd6647166b..113347cdc323 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp @@ -115,7 +115,7 @@ static scf::ForOp createFor(OpBuilder &builder, Location loc, Value upper, } /// Gets the dimension size for the given sparse tensor at the given -/// original dimension 'dim'. Returns None if no sparse encoding is +/// original dimension 'dim'. Returns std::nullopt if no sparse encoding is /// attached to the given tensor type. static Optional sizeFromTensorAtDim(OpBuilder &builder, Location loc, RankedTensorType tensorTp, diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp index b763f2bb1b3b..272f7675df44 100644 --- a/mlir/lib/Dialect/Traits.cpp +++ b/mlir/lib/Dialect/Traits.cpp @@ -148,7 +148,7 @@ Type OpTrait::util::getBroadcastedType(Type type1, Type type2, } // Returns the type kind if the given type is a vector or ranked tensor type. - // Returns llvm::None otherwise. + // Returns std::nullopt otherwise. auto getCompositeTypeKind = [](Type type) -> Optional { if (type.isa()) return type.getTypeID(); diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp index c4d16d43e819..c59972a867be 100644 --- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp @@ -132,8 +132,8 @@ static Operation *cloneOpWithOperandsAndTypes(OpBuilder &builder, Location loc, resultTypes, op->getAttrs()); } -/// Return the target shape for unrolling for the given `op`. Return llvm::None -/// if the op shouldn't be or cannot be unrolled. +/// Return the target shape for unrolling for the given `op`. Return +/// std::nullopt if the op shouldn't be or cannot be unrolled. static Optional> getTargetShape(const vector::UnrollVectorOptions &options, Operation *op) { if (options.filterConstraint && failed(options.filterConstraint(op))) diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp index 0046590c0394..99f738072777 100644 --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -92,7 +92,7 @@ static bool dictionaryAttrSort(ArrayRef value, } /// Returns an entry with a duplicate name from the given sorted array of named -/// attributes. Returns llvm::None if all elements have unique names. +/// attributes. Returns std::nullopt if all elements have unique names. static Optional findDuplicateElement(ArrayRef value) { const Optional none{std::nullopt}; diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp index 3dfaa12393fb..378b87d1284c 100644 --- a/mlir/lib/IR/BuiltinTypes.cpp +++ b/mlir/lib/IR/BuiltinTypes.cpp @@ -385,8 +385,8 @@ unsigned BaseMemRefType::getMemorySpaceAsInt() const { /// `reducedShape`. The returned mask can be applied as a projection to /// `originalShape` to obtain the `reducedShape`. This mask is useful to track /// which dimensions must be kept when e.g. compute MemRef strides under -/// rank-reducing operations. Return None if reducedShape cannot be obtained -/// by dropping only `1` entries in `originalShape`. +/// rank-reducing operations. Return std::nullopt if reducedShape cannot be +/// obtained by dropping only `1` entries in `originalShape`. llvm::Optional> mlir::computeRankReductionMask(ArrayRef originalShape, ArrayRef reducedShape) { diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index 54ab2f58dd6a..1f659d404cce 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -778,8 +778,8 @@ static Optional getSymbolUsesImpl(SymbolT symbol, /// Get all of the uses of the given symbol that are nested within the given /// operation 'from', invoking the provided callback for each. This does not -/// traverse into any nested symbol tables. This function returns None if there -/// are any unknown operations that may potentially be symbol tables. +/// traverse into any nested symbol tables. This function returns std::nullopt +/// if there are any unknown operations that may potentially be symbol tables. auto SymbolTable::getSymbolUses(StringAttr symbol, Operation *from) -> Optional { return getSymbolUsesImpl(symbol, from); diff --git a/mlir/lib/TableGen/CodeGenHelpers.cpp b/mlir/lib/TableGen/CodeGenHelpers.cpp index 988aff6a4357..589e99280b4a 100644 --- a/mlir/lib/TableGen/CodeGenHelpers.cpp +++ b/mlir/lib/TableGen/CodeGenHelpers.cpp @@ -77,7 +77,7 @@ StringRef StaticVerifierFunctionEmitter::getTypeConstraintFn( } // Find a uniqued attribute constraint. Since not all attribute constraints can -// be uniqued, return None if one was not found. +// be uniqued, return std::nullopt if one was not found. Optional StaticVerifierFunctionEmitter::getAttrConstraintFn( const Constraint &constraint) const { auto it = attrConstraints.find(constraint); diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index bb65c1bcc8b3..eacfbd4e0f02 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -40,7 +40,7 @@ StringRef TypeConstraint::getVariadicOfVariadicSegmentSizeAttr() const { } // Returns the builder call for this constraint if this is a buildable type, -// returns None otherwise. +// returns std::nullopt otherwise. Optional TypeConstraint::getBuilderCall() const { const llvm::Record *baseType = def; if (isVariableLength()) diff --git a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h index 69e0584501cd..75f739d6b064 100644 --- a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h +++ b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.h @@ -29,7 +29,7 @@ namespace lsp { SMRange convertTokenLocToRange(SMLoc loc); /// Extract a documentation comment for the given location within the source -/// manager. Returns None if no comment could be computed. +/// manager. Returns std::nullopt if no comment could be computed. Optional extractSourceDocComment(llvm::SourceMgr &sourceMgr, SMLoc loc); diff --git a/mlir/lib/Tools/lsp-server-support/Transport.cpp b/mlir/lib/Tools/lsp-server-support/Transport.cpp index 0b4c74e1ce52..b400e75555a4 100644 --- a/mlir/lib/Tools/lsp-server-support/Transport.cpp +++ b/mlir/lib/Tools/lsp-server-support/Transport.cpp @@ -286,7 +286,7 @@ LogicalResult readLine(std::FILE *in, SmallVectorImpl &out) { } } -// Returns None when: +// Returns std::nullopt when: // - ferror(), feof(), or shutdownRequested() are set. // - Content-Length is missing or empty (protocol error) LogicalResult JSONTransport::readStandardMessage(std::string &json) { diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index 0c60c7123a9f..150e731e99e5 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -153,7 +153,7 @@ static Optional getResultNumberFromLoc(SMLoc loc) { } /// Given a source location range, return the text covered by the given range. -/// If the range is invalid, returns None. +/// If the range is invalid, returns std::nullopt. static Optional getTextFromRange(SMRange range) { if (!range.isValid()) return std::nullopt; diff --git a/mlir/tools/mlir-tblgen/DialectGenUtilities.h b/mlir/tools/mlir-tblgen/DialectGenUtilities.h index 80fed9626deb..e36bf0e0b1d1 100644 --- a/mlir/tools/mlir-tblgen/DialectGenUtilities.h +++ b/mlir/tools/mlir-tblgen/DialectGenUtilities.h @@ -15,8 +15,8 @@ namespace mlir { namespace tblgen { class Dialect; -/// Find the dialect selected by the user to generate for. Returns None if no -/// dialect was found, or if more than one potential dialect was found. +/// Find the dialect selected by the user to generate for. Returns std::nullopt +/// if no dialect was found, or if more than one potential dialect was found. Optional findDialectToGenerate(ArrayRef dialects); } // namespace tblgen } // namespace mlir diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index 4543b9db0325..3dbda021c2da 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -226,7 +226,7 @@ static void emitMaxValueFn(const Record &enumDef, raw_ostream &os) { os << "}\n\n"; } -// Returns the EnumAttrCase whose value is zero if exists; returns llvm::None +// Returns the EnumAttrCase whose value is zero if exists; returns std::nullopt // otherwise. static llvm::Optional getAllBitsUnsetCase(llvm::ArrayRef cases) { diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index 861bfa758cbc..07a6ab9c2b71 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -2471,7 +2471,7 @@ static Optional checkRangeForElement( // We found a closing element that is valid. return success(); } - // Return None to indicate that we reached the end. + // Return std::nullopt to indicate that we reached the end. return std::nullopt; } diff --git a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp index b38f137c7c24..ae9df279dd27 100644 --- a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp +++ b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp @@ -52,8 +52,8 @@ static void dump(ArrayRef vec) { /// for the IntegerPolyhedron poly. Also check that getIntegerLexmin finds a /// non-empty lexmin. /// -/// If hasSample is false, check that findIntegerSample returns None and -/// findIntegerLexMin returns Empty. +/// If hasSample is false, check that findIntegerSample returns std::nullopt +/// and findIntegerLexMin returns Empty. /// /// If fn is TestFunction::Empty, check that isIntegerEmpty returns the /// opposite of hasSample.