From 595f1a6aaf5465fd71884b1557b4451be4e6a282 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 4 Dec 2022 19:47:13 -0800 Subject: [PATCH] [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 --- .../llvm/Analysis/BranchProbabilityInfo.h | 2 +- .../llvm/Analysis/LoopAccessAnalysis.h | 2 +- llvm/include/llvm/BinaryFormat/Dwarf.h | 4 +-- llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 2 +- .../DebugInfo/DWARF/DWARFAcceleratorTable.h | 24 +++++++-------- .../llvm/DebugInfo/DWARF/DWARFDebugFrame.h | 2 +- llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h | 10 +++---- .../llvm/DebugInfo/DWARF/DWARFFormValue.h | 4 +-- llvm/include/llvm/DebugInfo/GSYM/GsymReader.h | 6 ++-- llvm/include/llvm/DebugInfo/GSYM/LineTable.h | 4 +-- .../include/llvm/DebugInfo/Symbolize/Markup.h | 2 +- llvm/include/llvm/IR/Attributes.h | 11 +++---- llvm/include/llvm/IR/Constants.h | 2 +- llvm/include/llvm/IR/DebugInfoMetadata.h | 8 ++--- llvm/include/llvm/IR/Operator.h | 4 +-- llvm/include/llvm/Object/Minidump.h | 4 +-- llvm/include/llvm/Support/Program.h | 2 +- .../llvm/Testing/Support/SupportHelpers.h | 2 +- .../include/llvm/Transforms/Utils/LoopUtils.h | 6 ++-- .../LiveDebugValues/InstrRefBasedImpl.cpp | 8 ++--- .../LiveDebugValues/InstrRefBasedImpl.h | 10 +++---- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 2 +- llvm/lib/DebugInfo/Symbolize/Markup.cpp | 2 +- llvm/lib/FileCheck/FileCheckImpl.h | 30 +++++++++---------- .../ProfileData/Coverage/CoverageMapping.cpp | 3 +- .../AArch64/AArch64CompressJumpTables.cpp | 4 +-- llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h | 2 +- .../PowerPC/MCTargetDesc/PPCELFStreamer.cpp | 8 ++--- .../WebAssembly/WebAssemblyFrameLowering.h | 2 +- llvm/lib/Transforms/IPO/Attributor.cpp | 12 ++++---- .../Transforms/IPO/AttributorAttributes.cpp | 2 +- llvm/lib/Transforms/IPO/IROutliner.cpp | 4 +-- llvm/lib/Transforms/Scalar/Scalarizer.cpp | 3 +- .../Vectorize/LoopVectorizationPlanner.h | 4 +-- 34 files changed, 100 insertions(+), 97 deletions(-) diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h index 51c6ef3fccd9..66074f445e1a 100644 --- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h +++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h @@ -371,7 +371,7 @@ private: /// Iterates over all edges leading from \p SrcBB to \p Successors and /// returns maximum of all estimated weights. If at least one edge has unknown - /// estimated weight None is returned. + /// estimated weight std::nullopt is returned. template Optional getMaxEstimatedEdgeWeight(const LoopBlock &SrcBB, diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h index ee5e3f74b41c..67a7f9ce0bc0 100644 --- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -452,7 +452,7 @@ public: // pairs that can be used to prove that there are no vectorization-preventing // dependencies at runtime. There are is a vectorization-preventing dependency // if any pointer-difference is > getDiffChecks() const { if (!CanUseDiffCheck) return std::nullopt; diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 2b49c375acb3..72e008d8a92c 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -694,8 +694,8 @@ inline uint8_t getUnitLengthFieldByteSize(DwarfFormat Format) { /// /// \param Form DWARF form to get the fixed byte size for. /// \param Params DWARF parameters to help interpret forms. -/// \returns std::optional value with the fixed byte size or None if -/// \p Form doesn't have a fixed byte size. +/// \returns std::optional value with the fixed byte size or +/// std::nullopt if \p Form doesn't have a fixed byte size. std::optional getFixedFormByteSize(dwarf::Form Form, FormParams Params); diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h index 213891c14964..c236aa7f2457 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -473,7 +473,7 @@ bool isConstantOrConstantVector(MachineInstr &MI, /// Determines if \p MI defines a constant integer or a splat vector of /// constant integers. -/// \returns the scalar constant or None. +/// \returns the scalar constant or std::nullopt. Optional isConstantOrConstantSplatVector(MachineInstr &MI, const MachineRegisterInfo &MRI); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index aad46b945adf..278a1b871a97 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -51,12 +51,12 @@ public: public: /// Returns the Offset of the Compilation Unit associated with this - /// Accelerator Entry or None if the Compilation Unit offset is not recorded - /// in this Accelerator Entry. + /// Accelerator Entry or std::nullopt if the Compilation Unit offset is not + /// recorded in this Accelerator Entry. virtual std::optional getCUOffset() const = 0; /// Returns the Tag of the Debug Info Entry associated with this - /// Accelerator Entry or None if the Tag is not recorded in this + /// Accelerator Entry or std::nullopt if the Tag is not recorded in this /// Accelerator Entry. virtual std::optional getTag() const = 0; @@ -126,9 +126,9 @@ public: std::optional getCUOffset() const override; /// Returns the Section Offset of the Debug Info Entry associated with this - /// Accelerator Entry or None if the DIE offset is not recorded in this - /// Accelerator Entry. The returned offset is relative to the start of the - /// Section containing the DIE. + /// Accelerator Entry or std::nullopt if the DIE offset is not recorded in + /// this Accelerator Entry. The returned offset is relative to the start of + /// the Section containing the DIE. std::optional getDIESectionOffset() const; std::optional getTag() const override; @@ -292,12 +292,12 @@ public: std::optional getTag() const override { return tag(); } /// Returns the Index into the Compilation Unit list of the owning Name - /// Index or None if this Accelerator Entry does not have an associated - /// Compilation Unit. It is up to the user to verify that the returned Index - /// is valid in the owning NameIndex (or use getCUOffset(), which will - /// handle that check itself). Note that entries in NameIndexes which index - /// just a single Compilation Unit are implicitly associated with that unit, - /// so this function will return 0 even without an explicit + /// Index or std::nullopt if this Accelerator Entry does not have an + /// associated Compilation Unit. It is up to the user to verify that the + /// returned Index is valid in the owning NameIndex (or use getCUOffset(), + /// which will handle that check itself). Note that entries in NameIndexes + /// which index just a single Compilation Unit are implicitly associated + /// with that unit, so this function will return 0 even without an explicit /// DW_IDX_compile_unit attribute. std::optional getCUIndex() const; diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h index 9dfe95aa7131..6f25964ef42b 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -187,7 +187,7 @@ public: /// /// \param RegNum the register number to find a location for. /// - /// \returns A location if one is available for \a RegNum, or llvm::None + /// \returns A location if one is available for \a RegNum, or std::nullopt /// otherwise. std::optional getRegisterLocation(uint32_t RegNum) const { auto Pos = Locations.find(RegNum); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h index 90f59138fc19..421b84d644db 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -149,8 +149,8 @@ public: /// /// \param Attrs an array of DWARF attribute to look for. /// \returns an optional that has a valid DWARFFormValue for the first - /// matching attribute in Attrs, or None if none of the attributes in Attrs - /// exist in this DIE. + /// matching attribute in Attrs, or std::nullopt if none of the attributes in + /// Attrs exist in this DIE. std::optional find(ArrayRef Attrs) const; /// Extract the first value of any attribute in Attrs from this DIE and @@ -159,9 +159,9 @@ public: /// /// \param Attrs an array of DWARF attribute to look for. /// \returns an optional that has a valid DWARFFormValue for the first - /// matching attribute in Attrs, or None if none of the attributes in Attrs - /// exist in this DIE or in any DW_AT_specification or DW_AT_abstract_origin - /// DIEs. + /// matching attribute in Attrs, or std::nullopt if none of the attributes in + /// Attrs exist in this DIE or in any DW_AT_specification or + /// DW_AT_abstract_origin DIEs. std::optional findRecursively(ArrayRef Attrs) const; diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h index e9944a1fbee6..5a78003b803a 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -129,8 +129,8 @@ public: /// /// \param Kind The kind of path to extract. /// - /// \returns A valid string value on success, or llvm::None if the form class - /// is not FC_Constant, or if the file index is not valid. + /// \returns A valid string value on success, or std::nullopt if the form + /// class is not FC_Constant, or if the file index is not valid. std::optional getAsFile(DILineInfoSpecifier::FileLineInfoKind Kind) const; diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h index f2ac33be3bbe..5c0ab87dca30 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h +++ b/llvm/include/llvm/DebugInfo/GSYM/GsymReader.h @@ -137,7 +137,7 @@ public: /// /// \param Index An index into the file table. /// \returns An optional FileInfo that will be valid if the file index is - /// valid, or llvm::None if the file index is out of bounds, + /// valid, or std::nullopt if the file index is out of bounds, std::optional getFile(uint32_t Index) const { if (Index < Files.size()) return Files[Index]; @@ -204,7 +204,7 @@ public: /// /// \param Index A index into the address table. /// \returns A resolved virtual address for adddress in the address table - /// or llvm::None if Index is out of bounds. + /// or std::nullopt if Index is out of bounds. std::optional getAddress(size_t Index) const; protected: @@ -236,7 +236,7 @@ protected: /// /// \param Index An index into the AddrOffsets array. /// \returns An virtual address that matches the original object file for the - /// address as the specified index, or llvm::None if Index is out of bounds. + /// address as the specified index, or std::nullopt if Index is out of bounds. template std::optional addressForIndex(size_t Index) const { ArrayRef AIO = getAddrOffsets(); diff --git a/llvm/include/llvm/DebugInfo/GSYM/LineTable.h b/llvm/include/llvm/DebugInfo/GSYM/LineTable.h index a27019fc769d..7749e5e4fbb3 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/LineTable.h +++ b/llvm/include/llvm/DebugInfo/GSYM/LineTable.h @@ -169,7 +169,7 @@ public: /// Return the first line entry if the line table isn't empty. /// /// \returns An optional line entry with the first line entry if the line - /// table isn't empty, or llvm::None if the line table is emtpy. + /// table isn't empty, or std::nullopt if the line table is emtpy. std::optional first() const { if (Lines.empty()) return std::nullopt; @@ -178,7 +178,7 @@ public: /// Return the last line entry if the line table isn't empty. /// /// \returns An optional line entry with the last line entry if the line - /// table isn't empty, or llvm::None if the line table is emtpy. + /// table isn't empty, or std::nullopt if the line table is emtpy. std::optional last() const { if (Lines.empty()) return std::nullopt; diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Markup.h b/llvm/include/llvm/DebugInfo/Symbolize/Markup.h index c6242267f1e2..37e1d2748e31 100644 --- a/llvm/include/llvm/DebugInfo/Symbolize/Markup.h +++ b/llvm/include/llvm/DebugInfo/Symbolize/Markup.h @@ -78,7 +78,7 @@ public: /// Calling nextNode() may invalidate the contents of the node returned by the /// previous call. /// - /// \returns the next markup node or None if none remain. + /// \returns the next markup node or std::nullopt if none remain. std::optional nextNode(); bool isSGR(const MarkupNode &Node) const { diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h index 505b42b948ff..cb7900343d67 100644 --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -235,8 +235,8 @@ public: /// Returns the minimum value for the vscale_range attribute. unsigned getVScaleRangeMin() const; - /// Returns the maximum value for the vscale_range attribute or None when - /// unknown. + /// Returns the maximum value for the vscale_range attribute or std::nullopt + /// when unknown. std::optional getVScaleRangeMax() const; // Returns the unwind table kind. @@ -1105,8 +1105,8 @@ public: /// invalid if the Kind is not present in the builder. Attribute getAttribute(StringRef Kind) const; - /// Return raw (possibly packed/encoded) value of integer attribute or None if - /// not set. + /// Return raw (possibly packed/encoded) value of integer attribute or + /// std::nullopt if not set. std::optional getRawIntAttr(Attribute::AttrKind Kind) const; /// Retrieve the alignment attribute, if it exists. @@ -1151,7 +1151,8 @@ public: /// Retrieve the inalloca type. Type *getInAllocaType() const { return getTypeAttr(Attribute::InAlloca); } - /// Retrieve the allocsize args, or None if the attribute does not exist. + /// Retrieve the allocsize args, or std::nullopt if the attribute does not + /// exist. std::optional>> getAllocSizeArgs() const; diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index b3b46385c90f..d39445832f79 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1213,7 +1213,7 @@ public: /// Getelementptr form. Value* is only accepted for convenience; /// all elements must be Constants. /// - /// \param InRangeIndex the inrange index if present or None. + /// \param InRangeIndex the inrange index if present or std::nullopt. /// \param OnlyIfReducedTy see \a getWithOperands() docs. static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef IdxList, diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 534de3d72b65..c85c21ddd9f1 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -860,8 +860,8 @@ public: enum class Signedness { Signed, Unsigned }; - /// Return the signedness of this type, or None if this type is neither - /// signed nor unsigned. + /// Return the signedness of this type, or std::nullopt if this type is + /// neither signed nor unsigned. std::optional getSignedness() const; static bool classof(const Metadata *MD) { @@ -2552,8 +2552,8 @@ public: /// Determines the size of the variable's type. std::optional getSizeInBits() const; - /// Return the signedness of this variable's type, or None if this type is - /// neither signed nor unsigned. + /// Return the signedness of this variable's type, or std::nullopt if this + /// type is neither signed nor unsigned. std::optional getSignedness() const { if (auto *BT = dyn_cast(getType())) return BT->getSignedness(); diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h index 2c2c86385bf3..ed52535c0b6e 100644 --- a/llvm/include/llvm/IR/Operator.h +++ b/llvm/include/llvm/IR/Operator.h @@ -393,8 +393,8 @@ public: return SubclassOptionalData & IsInBounds; } - /// Returns the offset of the index with an inrange attachment, or None if - /// none. + /// Returns the offset of the index with an inrange attachment, or + /// std::nullopt if none. Optional getInRangeIndex() const { if (SubclassOptionalData >> 1 == 0) return std::nullopt; diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h index 4a0e8844e0e5..e45d4de0090d 100644 --- a/llvm/include/llvm/Object/Minidump.h +++ b/llvm/include/llvm/Object/Minidump.h @@ -40,8 +40,8 @@ public: return getData().slice(Stream.Location.RVA, Stream.Location.DataSize); } - /// Returns the raw contents of the stream of the given type, or None if the - /// file does not contain a stream of this type. + /// Returns the raw contents of the stream of the given type, or std::nullopt + /// if the file does not contain a stream of this type. std::optional> getRawStream(minidump::StreamType Type) const; diff --git a/llvm/include/llvm/Support/Program.h b/llvm/include/llvm/Support/Program.h index 5f1058920cd4..5aeb943266d0 100644 --- a/llvm/include/llvm/Support/Program.h +++ b/llvm/include/llvm/Support/Program.h @@ -117,7 +117,7 @@ namespace sys { ///< If the array is empty, no redirections are performed. ///< Otherwise, the inferior process's stdin(0), stdout(1), and stderr(2) ///< will be redirected to the corresponding paths, if the optional path - ///< is present (not \c llvm::None). + ///< is present (not \c std::nullopt). ///< When an empty path is passed in, the corresponding file descriptor ///< will be disconnected (ie, /dev/null'd) in a portable way. unsigned SecondsToWait = 0, ///< If non-zero, this specifies the amount diff --git a/llvm/include/llvm/Testing/Support/SupportHelpers.h b/llvm/include/llvm/Testing/Support/SupportHelpers.h index b1c59cf97f7f..2745e06e249c 100644 --- a/llvm/include/llvm/Testing/Support/SupportHelpers.h +++ b/llvm/include/llvm/Testing/Support/SupportHelpers.h @@ -99,7 +99,7 @@ private: } // namespace detail /// Matches an llvm::Optional with a value that conforms to an inner matcher. -/// To match llvm::None you could use Eq(llvm::None). +/// To match std::nullopt you could use Eq(std::nullopt). template detail::ValueIsMatcher ValueIs(const InnerMatcher &ValueMatcher) { return detail::ValueIsMatcher(ValueMatcher); diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h index 54d98c64a37e..5f7b839b7a85 100644 --- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h +++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h @@ -225,7 +225,7 @@ SmallVector findDefsUsedOutsideOfLoop(Loop *L); /// Find a combination of metadata ("llvm.loop.vectorize.width" and /// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a /// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found -/// then None is returned. +/// then std::nullopt is returned. Optional getOptionalElementCountLoopAttribute(const Loop *TheLoop); @@ -309,8 +309,8 @@ void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, /// Returns a loop's estimated trip count based on branch weight metadata. /// In addition if \p EstimatedLoopInvocationWeight is not null it is /// initialized with weight of loop's latch leading to the exit. -/// Returns 0 when the count is estimated to be 0, or None when a meaningful -/// estimate can not be made. +/// Returns 0 when the count is estimated to be 0, or std::nullopt when a +/// meaningful estimate can not be made. Optional getLoopEstimatedTripCount(Loop *L, unsigned *EstimatedLoopInvocationWeight = nullptr); diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 74e563109d9b..b65eceb37f4d 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -1543,10 +1543,10 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr &MI, } } - // We, we have a value number or None. Tell the variable value tracker about - // it. The rest of this LiveDebugValues implementation acts exactly the same - // for DBG_INSTR_REFs as DBG_VALUEs (just, the former can refer to values that - // aren't immediately available). + // We, we have a value number or std::nullopt. Tell the variable value tracker + // about it. The rest of this LiveDebugValues implementation acts exactly the + // same for DBG_INSTR_REFs as DBG_VALUEs (just, the former can refer to values + // that aren't immediately available). DbgValueProperties Properties(Expr, false, false); SmallVector DbgOpIDs; if (NewID) diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h index 27438da368ff..9d0f4d021ae3 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h @@ -1127,11 +1127,11 @@ private: uint64_t InstrNum; /// Block where DBG_PHI occurred. MachineBasicBlock *MBB; - /// The value number read by the DBG_PHI -- or None if it didn't refer to - /// a value. + /// The value number read by the DBG_PHI -- or std::nullopt if it didn't + /// refer to a value. Optional ValueRead; - /// Register/Stack location the DBG_PHI reads -- or None if it referred to - /// something unexpected. + /// Register/Stack location the DBG_PHI reads -- or std::nullopt if it + /// referred to something unexpected. Optional ReadLoc; operator unsigned() const { return InstrNum; } @@ -1229,7 +1229,7 @@ private: /// forming another mini-ssa problem to solve. /// \p Here the position of a DBG_INSTR_REF seeking a machine value number /// \p InstrNum Debug instruction number defined by DBG_PHI instructions. - /// \returns The machine value number at position Here, or None. + /// \returns The machine value number at position Here, or std::nullopt. Optional resolveDbgPHIs(MachineFunction &MF, const ValueTable *MLiveOuts, const ValueTable *MLiveIns, diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 5e56330ee732..548766792e6b 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -716,7 +716,7 @@ DWARFDebugLine::ParsingState::handleSpecialOpcode(uint8_t Opcode, } /// Parse a ULEB128 using the specified \p Cursor. \returns the parsed value on -/// success, or None if \p Cursor is in a failing state. +/// success, or std::nullopt if \p Cursor is in a failing state. template static std::optional parseULEB128(DWARFDataExtractor &Data, DataExtractor::Cursor &Cursor) { diff --git a/llvm/lib/DebugInfo/Symbolize/Markup.cpp b/llvm/lib/DebugInfo/Symbolize/Markup.cpp index ae3e24c0d500..a8e74afc8fc2 100644 --- a/llvm/lib/DebugInfo/Symbolize/Markup.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Markup.cpp @@ -110,7 +110,7 @@ void MarkupParser::flush() { } // Finds and returns the next valid markup element in the given line. Returns -// None if the line contains no valid elements. +// std::nullopt if the line contains no valid elements. std::optional MarkupParser::parseElement(StringRef Line) { while (true) { // Find next element using begin and end markers. diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h index ccfcda60b1c3..556be6b8bb0f 100644 --- a/llvm/lib/FileCheck/FileCheckImpl.h +++ b/llvm/lib/FileCheck/FileCheckImpl.h @@ -265,16 +265,16 @@ private: /// format. ExpressionFormat ImplicitFormat; - /// Value of numeric variable, if defined, or None otherwise. + /// Value of numeric variable, if defined, or std::nullopt otherwise. Optional Value; - /// The input buffer's string from which Value was parsed, or None. See - /// comments on getStringValue for a discussion of the None case. + /// The input buffer's string from which Value was parsed, or std::nullopt. + /// See comments on getStringValue for a discussion of the None case. Optional StrValue; - /// Line number where this variable is defined, or None if defined before - /// input is parsed. Used to determine whether a variable is defined on the - /// same line as a given use. + /// Line number where this variable is defined, or std::nullopt if defined + /// before input is parsed. Used to determine whether a variable is defined on + /// the same line as a given use. Optional DefLineNumber; public: @@ -296,9 +296,9 @@ public: Optional getValue() const { return Value; } /// \returns the input buffer's string from which this variable's value was - /// parsed, or None if the value is not yet defined or was not parsed from the - /// input buffer. For example, the value of @LINE is not parsed from the - /// input buffer, and some numeric variables are parsed from the command + /// parsed, or std::nullopt if the value is not yet defined or was not parsed + /// from the input buffer. For example, the value of @LINE is not parsed from + /// the input buffer, and some numeric variables are parsed from the command /// line instead. Optional getStringValue() const { return StrValue; } @@ -318,8 +318,8 @@ public: StrValue = std::nullopt; } - /// \returns the line number where this variable is defined, if any, or None - /// if defined before input is parsed. + /// \returns the line number where this variable is defined, if any, or + /// std::nullopt if defined before input is parsed. Optional getDefLineNumber() const { return DefLineNumber; } }; @@ -672,9 +672,9 @@ class Pattern { Check::FileCheckType CheckTy; - /// Line number for this CHECK pattern or None if it is an implicit pattern. - /// Used to determine whether a variable definition is made on an earlier - /// line to the one with this CHECK. + /// Line number for this CHECK pattern or std::nullopt if it is an implicit + /// pattern. Used to determine whether a variable definition is made on an + /// earlier line to the one with this CHECK. Optional LineNumber; /// Ignore case while matching if set to true. @@ -717,7 +717,7 @@ public: /// holding a diagnostic against \p SM if parsing fails. If substitution was /// successful, sets \p DefinedNumericVariable to point to the class /// representing the numeric variable defined in this numeric substitution - /// block, or None if this block does not define any variable. + /// block, or std::nullopt if this block does not define any variable. static Expected> parseNumericSubstitutionBlock( StringRef Expr, Optional &DefinedNumericVariable, bool IsLegacyLineExpr, Optional LineNumber, diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 51a2503c080f..ac3665068ac7 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -689,7 +689,8 @@ static Optional findMainViewFileID(const FunctionRecord &Function) { } /// Check if SourceFile is the file that contains the definition of -/// the Function. Return the ID of the file in that case or None otherwise. +/// the Function. Return the ID of the file in that case or std::nullopt +/// otherwise. static Optional findMainViewFileID(StringRef SourceFile, const FunctionRecord &Function) { Optional I = findMainViewFileID(Function); diff --git a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp index 05919c8faf95..75abe9c53e3b 100644 --- a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp +++ b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp @@ -37,8 +37,8 @@ class AArch64CompressJumpTables : public MachineFunctionPass { MachineFunction *MF; SmallVector BlockInfo; - /// Returns the size in instructions of the block \p MBB, or None if we - /// couldn't get a safe upper bound. + /// Returns the size in instructions of the block \p MBB, or std::nullopt if + /// we couldn't get a safe upper bound. std::optional computeBlockSize(MachineBasicBlock &MBB); /// Gather information about the function, returns false if we can't perform diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h index 24ec9b2e3655..d7812b84ca20 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h @@ -1237,7 +1237,7 @@ bool isLegalSMRDEncodedSignedOffset(const MCSubtargetInfo &ST, uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST, uint64_t ByteOffset); /// \returns The encoding that will be used for \p ByteOffset in the -/// SMRD offset field, or None if it won't fit. On GFX9 and GFX10 +/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10 /// S_LOAD instructions have a signed offset, on other subtargets it is /// unsigned. S_BUFFER has an unsigned offset for all subtargets. Optional getSMRDEncodedOffset(const MCSubtargetInfo &ST, diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp index 4428c4f50fee..dfc0409434de 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp @@ -191,10 +191,10 @@ void PPCELFStreamer::emitGOTToPCRelLabel(const MCInst &Inst) { // // >)>> // The above is a pair of such instructions and this function will not return -// None for either one of them. In both cases we are looking for the last -// operand >)> which needs to be an MCExpr -// and has the flag MCSymbolRefExpr::VK_PPC_PCREL_OPT. After that we just look -// at the opcode and in the case of PLDpc we will return true. For the load +// std::nullopt for either one of them. In both cases we are looking for the +// last operand >)> which needs to be an +// MCExpr and has the flag MCSymbolRefExpr::VK_PPC_PCREL_OPT. After that we just +// look at the opcode and in the case of PLDpc we will return true. For the load // (or store) this function will return false indicating it has found the second // instruciton in the pair. std::optional llvm::isPartOfGOTToPCRelPair(const MCInst &Inst, diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h index 13a05b0e4561..528b33e34bee 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h @@ -55,7 +55,7 @@ public: const DebugLoc &DL) const; // Returns the index of the WebAssembly local to which the stack object - // FrameIndex in MF should be allocated, or None. + // FrameIndex in MF should be allocated, or std::nullopt. static std::optional getLocalForStackObject(MachineFunction &MF, int FrameIndex); diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index ebb5c47b31fd..820a45408a82 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -1074,8 +1074,8 @@ Attributor::getAssumedConstant(const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation) { // First check all callbacks provided by outside AAs. If any of them returns - // a non-null value that is different from the associated value, or None, we - // assume it's simplified. + // a non-null value that is different from the associated value, or + // std::nullopt, we assume it's simplified. for (auto &CB : SimplificationCallbacks.lookup(IRP)) { Optional SimplifiedV = CB(IRP, &AA, UsedAssumedInformation); if (!SimplifiedV) @@ -1104,8 +1104,8 @@ Optional Attributor::getAssumedSimplified(const IRPosition &IRP, bool &UsedAssumedInformation, AA::ValueScope S) { // First check all callbacks provided by outside AAs. If any of them returns - // a non-null value that is different from the associated value, or None, we - // assume it's simplified. + // a non-null value that is different from the associated value, or + // std::nullopt, we assume it's simplified. for (auto &CB : SimplificationCallbacks.lookup(IRP)) return CB(IRP, AA, UsedAssumedInformation); @@ -1128,8 +1128,8 @@ bool Attributor::getAssumedSimplifiedValues( SmallVectorImpl &Values, AA::ValueScope S, bool &UsedAssumedInformation) { // First check all callbacks provided by outside AAs. If any of them returns - // a non-null value that is different from the associated value, or None, we - // assume it's simplified. + // a non-null value that is different from the associated value, or + // std::nullopt, we assume it's simplified. const auto &SimplificationCBs = SimplificationCallbacks.lookup(IRP); for (const auto &CB : SimplificationCBs) { Optional CBResult = CB(IRP, AA, UsedAssumedInformation); diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 4ce9611f1bf4..cc667e511bf8 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -9617,7 +9617,7 @@ private: Unreachable.erase(&Fn); } - /// If there is no information about the function None is returned. + /// If there is no information about the function std::nullopt is returned. Optional isCachedReachable(const Function &Fn) { // Assume that we can reach the function. // TODO: Be more specific with the unknown callee. diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index d4ff9f68852d..afa46f253bdb 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -1171,8 +1171,8 @@ static hash_code encodePHINodeData(PHINodeData &PND) { /// \param PN - The PHINode we are analyzing. /// \param Blocks - The blocks for the region we are analyzing. /// \param AggArgIdx - The argument \p PN will be stored into. -/// \returns An optional holding the assigned canonical number, or None if -/// there is some attribute of the PHINode blocking it from being used. +/// \returns An optional holding the assigned canonical number, or std::nullopt +/// if there is some attribute of the PHINode blocking it from being used. static Optional getGVNForPHINode(OutlinableRegion &Region, PHINode *PN, DenseSet &Blocks, diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp index 0316a1421684..3cab25649aca 100644 --- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp +++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp @@ -481,7 +481,8 @@ void ScalarizerVisitor::transferMetadataAndIRFlags(Instruction *Op, } // Try to fill in Layout from Ty, returning true on success. Alignment is -// the alignment of the vector, or None if the ABI default should be used. +// the alignment of the vector, or std::nullopt if the ABI default should be +// used. Optional ScalarizerVisitor::getVectorLayout(Type *Ty, Align Alignment, const DataLayout &DL) { diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h index 7c7307905e8d..4c635579b865 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h @@ -295,8 +295,8 @@ public: : OrigLoop(L), LI(LI), TLI(TLI), TTI(TTI), Legal(Legal), CM(CM), IAI(IAI), PSE(PSE), Hints(Hints), ORE(ORE) {} - /// Plan how to best vectorize, return the best VF and its cost, or None if - /// vectorization and interleaving should be avoided up front. + /// Plan how to best vectorize, return the best VF and its cost, or + /// std::nullopt if vectorization and interleaving should be avoided up front. Optional plan(ElementCount UserVF, unsigned UserIC); /// Use the VPlan-native path to plan how to best vectorize, return the best