[llvm] 8a7cbea - [llvm] Use std::nullopt instead of None in comments (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 23:22:07 PST 2022


Author: Kazu Hirata
Date: 2022-12-08T23:22:00-08:00
New Revision: 8a7cbea525ceb4bd67e8fe097bf071c449a8e525

URL: https://github.com/llvm/llvm-project/commit/8a7cbea525ceb4bd67e8fe097bf071c449a8e525
DIFF: https://github.com/llvm/llvm-project/commit/8a7cbea525ceb4bd67e8fe097bf071c449a8e525.diff

LOG: [llvm] 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

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/InlineCost.h
    llvm/include/llvm/Analysis/LoopCacheAnalysis.h
    llvm/include/llvm/Analysis/LoopInfo.h
    llvm/include/llvm/Analysis/ScalarEvolution.h
    llvm/include/llvm/BinaryFormat/Dwarf.h
    llvm/include/llvm/IR/GlobalValue.h
    llvm/include/llvm/IR/Instructions.h
    llvm/include/llvm/Support/CheckedArithmetic.h
    llvm/include/llvm/Support/Threading.h
    llvm/include/llvm/Transforms/IPO/Attributor.h
    llvm/include/llvm/Transforms/Utils/LoopUtils.h
    llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h
    llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
    llvm/lib/Target/SPIRV/SPIRVBuiltins.h
    llvm/lib/Transforms/Scalar/GVNSink.cpp
    llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h
index cef704bb783ff..bac159f37ddde 100644
--- a/llvm/include/llvm/Analysis/InlineCost.h
+++ b/llvm/include/llvm/Analysis/InlineCost.h
@@ -312,7 +312,7 @@ Optional<InlineResult> getAttributeBasedInliningDecision(
 /// Contrary to getInlineCost, which makes a threshold-based final evaluation of
 /// should/shouldn't inline, captured in InlineResult, getInliningCostEstimate
 /// returns:
-/// - None, if the inlining cannot happen (is illegal)
+/// - std::nullopt, if the inlining cannot happen (is illegal)
 /// - an integer, representing the cost.
 Optional<int> getInliningCostEstimate(
     CallBase &Call, TargetTransformInfo &CalleeTTI,

diff  --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index 6c5a3ad8cbc9d..2e4f0c469afee 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -79,7 +79,7 @@ class IndexedReference {
   /// Return true if the current object and the indexed reference \p Other
   /// have distance smaller than \p MaxDistance in the dimension associated with
   /// the given loop \p L. Return false if the distance is not smaller than \p
-  /// MaxDistance and None if unsure.
+  /// MaxDistance and std::nullopt if unsure.
   Optional<bool> hasTemporalReuse(const IndexedReference &Other,
                                   unsigned MaxDistance, const Loop &L,
                                   DependenceInfo &DI, AAResults &AA) const;

diff  --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index 865b17b6cb12a..278ad92aaa3ba 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -750,7 +750,7 @@ class LLVM_EXTERNAL_VISIBILITY Loop : public LoopBase<BasicBlock, Loop> {
   };
 
   /// Return the struct LoopBounds collected if all struct members are found,
-  /// else None.
+  /// else std::nullopt.
   Optional<LoopBounds> getBounds(ScalarEvolution &SE) const;
 
   /// Return the loop induction variable if found, else return nullptr.

diff  --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index dde0dcc4bb1cf..48fd94b14e718 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1190,7 +1190,7 @@ class ScalarEvolution {
       SmallPtrSetImpl<const SCEVPredicate *> &Preds);
 
   /// Compute \p LHS - \p RHS and returns the result as an APInt if it is a
-  /// constant, and None if it isn't.
+  /// constant, and std::nullopt if it isn't.
   ///
   /// This is intended to be a cheaper version of getMinusSCEV.  We can be
   /// frugal here since we just bail out of actually constructing and

diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 89b239c37245e..fedf98a0e5e1e 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -708,7 +708,7 @@ inline uint8_t getUnitLengthFieldByteSize(DwarfFormat Format) {
 ///
 /// If the form has a fixed byte size, then an Optional with a value will be
 /// returned. If the form is always encoded using a variable length storage
-/// format (ULEB or SLEB numbers or blocks) then None will be returned.
+/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned.
 ///
 /// \param Form DWARF form to get the fixed byte size for.
 /// \param Params DWARF parameters to help interpret forms.

diff  --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h
index b0e17d9553f79..d1891c157099d 100644
--- a/llvm/include/llvm/IR/GlobalValue.h
+++ b/llvm/include/llvm/IR/GlobalValue.h
@@ -638,7 +638,7 @@ class GlobalValue : public Constant {
   bool isAbsoluteSymbolRef() const;
 
   /// If this is an absolute symbol reference, returns the range of the symbol,
-  /// otherwise returns None.
+  /// otherwise returns std::nullopt.
   std::optional<ConstantRange> getAbsoluteSymbolRange() const;
 
   /// This method unlinks 'this' from the containing module, but does not delete

diff  --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 55486e5ef6477..0af65c936597a 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -5409,7 +5409,7 @@ inline Type *getLoadStoreType(Value *I) {
 }
 
 /// A helper function that returns an atomic operation's sync scope; returns
-/// None if it is not an atomic operation.
+/// std::nullopt if it is not an atomic operation.
 inline std::optional<SyncScope::ID> getAtomicSyncScopeID(const Instruction *I) {
   if (!I->isAtomic())
     return std::nullopt;

diff  --git a/llvm/include/llvm/Support/CheckedArithmetic.h b/llvm/include/llvm/Support/CheckedArithmetic.h
index 5bfc551b2cc5b..81b703a038921 100644
--- a/llvm/include/llvm/Support/CheckedArithmetic.h
+++ b/llvm/include/llvm/Support/CheckedArithmetic.h
@@ -42,7 +42,7 @@ namespace llvm {
 
 /// Add two signed integers \p LHS and \p RHS.
 /// \return Optional of sum if no signed overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_signed<T>::value, std::optional<T>>
 checkedAdd(T LHS, T RHS) {
@@ -51,7 +51,7 @@ checkedAdd(T LHS, T RHS) {
 
 /// Subtract two signed integers \p LHS and \p RHS.
 /// \return Optional of sum if no signed overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_signed<T>::value, std::optional<T>>
 checkedSub(T LHS, T RHS) {
@@ -60,7 +60,7 @@ checkedSub(T LHS, T RHS) {
 
 /// Multiply two signed integers \p LHS and \p RHS.
 /// \return Optional of product if no signed overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_signed<T>::value, std::optional<T>>
 checkedMul(T LHS, T RHS) {
@@ -69,7 +69,7 @@ checkedMul(T LHS, T RHS) {
 
 /// Multiply A and B, and add C to the resulting product.
 /// \return Optional of result if no signed overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_signed<T>::value, std::optional<T>>
 checkedMulAdd(T A, T B, T C) {
@@ -80,7 +80,7 @@ checkedMulAdd(T A, T B, T C) {
 
 /// Add two unsigned integers \p LHS and \p RHS.
 /// \return Optional of sum if no unsigned overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_unsigned<T>::value, std::optional<T>>
 checkedAddUnsigned(T LHS, T RHS) {
@@ -89,7 +89,7 @@ checkedAddUnsigned(T LHS, T RHS) {
 
 /// Multiply two unsigned integers \p LHS and \p RHS.
 /// \return Optional of product if no unsigned overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_unsigned<T>::value, std::optional<T>>
 checkedMulUnsigned(T LHS, T RHS) {
@@ -98,7 +98,7 @@ checkedMulUnsigned(T LHS, T RHS) {
 
 /// Multiply unsigned integers A and B, and add C to the resulting product.
 /// \return Optional of result if no unsigned overflow occurred,
-/// \c None otherwise.
+/// \c std::nullopt otherwise.
 template <typename T>
 std::enable_if_t<std::is_unsigned<T>::value, std::optional<T>>
 checkedMulAddUnsigned(T A, T B, T C) {

diff  --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h
index ce8dbff510e8a..ba6c531ab4db2 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -139,8 +139,8 @@ constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; }
     /// compute_thread_count()).
     void apply_thread_strategy(unsigned ThreadPoolNum) const;
 
-    /// Finds the CPU socket where a thread should go. Returns 'None' if the
-    /// thread shall remain on the actual CPU socket.
+    /// Finds the CPU socket where a thread should go. Returns 'std::nullopt' if
+    /// the thread shall remain on the actual CPU socket.
     std::optional<unsigned> compute_cpu_socket(unsigned ThreadPoolNum) const;
   };
 

diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index c78404e9a66d1..28cb568f081ea 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -4100,7 +4100,8 @@ struct AAPrivatizablePtr
   bool isKnownPrivatizablePtr() const { return getKnown(); }
 
   /// Return the type we can choose for a private copy of the underlying
-  /// value. None means it is not clear yet, nullptr means there is none.
+  /// value. std::nullopt means it is not clear yet, nullptr means there is
+  /// none.
   virtual std::optional<Type *> getPrivatizableType() const = 0;
 
   /// Create an abstract attribute view for the position \p IRP.

diff  --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index 5f7b839b7a859..4f9c97708a5eb 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -244,11 +244,11 @@ getOptionalElementCountLoopAttribute(const Loop *TheLoop);
 ///                    <prefix>; commonly used to remove metadata for the
 ///                    applied transformation.
 /// @param AlwaysNew If true, do not try to reuse OrigLoopID and never return
-///                  None.
+///                  std::nullopt.
 ///
 /// @return The loop ID for the after-transformation loop. The following values
 ///         can be returned:
-///         None         : No followup attribute was found; it is up to the
+///         std::nullopt : No followup attribute was found; it is up to the
 ///                        transformation to choose attributes that make sense.
 ///         @p OrigLoopID: The original identifier can be reused.
 ///         nullptr      : The new loop has no attributes.

diff  --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 932b3bd377d42..255e9a2255d90 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -97,8 +97,8 @@ static unsigned bigEndianByteAt(const unsigned ByteWidth, const unsigned I) {
 /// \param MemOffset2Idx maps memory offsets to address offsets.
 /// \param LowestIdx is the lowest index in \p MemOffset2Idx.
 ///
-/// \returns true if the map corresponds to a big endian byte pattern, false
-/// if it corresponds to a little endian byte pattern, and None otherwise.
+/// \returns true if the map corresponds to a big endian byte pattern, false if
+/// it corresponds to a little endian byte pattern, and std::nullopt otherwise.
 ///
 /// E.g. given a 32-bit type x, and x[AddrOffset], the in-memory byte patterns
 /// are as follows:

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b63dc0594654c..4aaae27e87402 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8074,7 +8074,7 @@ static unsigned bigEndianByteAt(unsigned BW, unsigned i) {
 
 // Check if the bytes offsets we are looking at match with either big or
 // little endian value loaded. Return true for big endian, false for little
-// endian, and None if match failed.
+// endian, and std::nullopt if match failed.
 static Optional<bool> isBigEndian(const ArrayRef<int64_t> ByteOffsets,
                                   int64_t FirstOffset) {
   // The endian can be decided only when it is 2 bytes at least.

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 2ad7d8e6763af..6592d515f7794 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -4360,7 +4360,7 @@ static SDValue addRequiredExtensionForVectorMULL(SDValue N, SelectionDAG &DAG,
 }
 
 // Returns lane if Op extracts from a two-element vector and lane is constant
-// (i.e., extractelt(<2 x Ty> %v, ConstantLane)), and None otherwise.
+// (i.e., extractelt(<2 x Ty> %v, ConstantLane)), and std::nullopt otherwise.
 static std::optional<uint64_t>
 getConstantLaneNumOfExtractHalfOperand(SDValue &Op) {
   SDNode *OpNode = Op.getNode();

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h
index 3a23b712da9f5..b6d37cf2918dc 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h
@@ -46,7 +46,7 @@ class AMDGPUMachineModuleInfo final : public MachineModuleInfoELF {
   /// larger synchronization scope is inclusive of a smaller synchronization
   /// scope.
   ///
-  /// \returns \p SSID's inclusion ordering, or "None" if \p SSID is not
+  /// \returns \p SSID's inclusion ordering, or "std::nullopt" if \p SSID is not
   /// supported by the AMDGPU target.
   Optional<uint8_t> getSyncScopeInclusionOrdering(SyncScope::ID SSID) const {
     if (SSID == SyncScope::SingleThread ||

diff  --git a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
index 65d95e54fe414..2cbfcca550ef8 100644
--- a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
@@ -237,21 +237,22 @@ class SIMemOpAccess final {
   /// of instructions in the machine function \p MF.
   SIMemOpAccess(MachineFunction &MF);
 
-  /// \returns Load info if \p MI is a load operation, "None" otherwise.
+  /// \returns Load info if \p MI is a load operation, "std::nullopt" otherwise.
   Optional<SIMemOpInfo> getLoadInfo(
       const MachineBasicBlock::iterator &MI) const;
 
-  /// \returns Store info if \p MI is a store operation, "None" otherwise.
+  /// \returns Store info if \p MI is a store operation, "std::nullopt"
+  /// otherwise.
   Optional<SIMemOpInfo> getStoreInfo(
       const MachineBasicBlock::iterator &MI) const;
 
   /// \returns Atomic fence info if \p MI is an atomic fence operation,
-  /// "None" otherwise.
+  /// "std::nullopt" otherwise.
   Optional<SIMemOpInfo> getAtomicFenceInfo(
       const MachineBasicBlock::iterator &MI) const;
 
   /// \returns Atomic cmpxchg/rmw info if \p MI is an atomic cmpxchg or
-  /// rmw operation, "None" otherwise.
+  /// rmw operation, "std::nullopt" otherwise.
   Optional<SIMemOpInfo> getAtomicCmpxchgOrRmwInfo(
       const MachineBasicBlock::iterator &MI) const;
 };

diff  --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.h b/llvm/lib/Target/SPIRV/SPIRVBuiltins.h
index 26ffe69659510..26d2e8ab0fd6b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.h
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.h
@@ -23,7 +23,7 @@ namespace SPIRV {
 /// and external instruction \p Set.
 ///
 /// \return the lowering success status if the called function is a recognized
-/// builtin, None otherwise.
+/// builtin, std::nullopt otherwise.
 ///
 /// \p DemangledCall is the skeleton of the lowered builtin function call.
 /// \p Set is the external instruction set containing the given builtin.

diff  --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 4fba9f812eb6d..b44f20addd5a8 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -599,7 +599,7 @@ class GVNSink {
 
   /// The main heuristic function. Analyze the set of instructions pointed to by
   /// LRI and return a candidate solution if these instructions can be sunk, or
-  /// None otherwise.
+  /// std::nullopt otherwise.
   Optional<SinkingInstructionCandidate> analyzeInstructionForSinking(
       LockstepReverseIterator &LRI, unsigned &InstNum, unsigned &MemoryInstNum,
       ModelledPHISet &NeededPHIs, SmallPtrSetImpl<Value *> &PHIContents);

diff  --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 148af5a9e2be9..1b7b9d9003ccf 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -343,7 +343,7 @@ struct PragmaInfo {
 /// cost of the 'false'-block).
 /// \returns Optional value, holding the RolledDynamicCost and UnrolledCost. If
 /// the analysis failed (no benefits expected from the unrolling, or the loop is
-/// too big to analyze), the returned value is None.
+/// too big to analyze), the returned value is std::nullopt.
 static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
     const Loop *L, unsigned TripCount, DominatorTree &DT, ScalarEvolution &SE,
     const SmallPtrSetImpl<const Value *> &EphValues,


        


More information about the llvm-commits mailing list