From 3c09ed006ab35dd8faac03311b14f0857b01949c Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 4 Dec 2022 17:12:44 -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/include/llvm/ADT/APInt.h | 2 +- llvm/include/llvm/ADT/Optional.h | 4 ++-- .../include/llvm/Analysis/IRSimilarityIdentifier.h | 4 ++-- llvm/include/llvm/Analysis/InlineCost.h | 4 ++-- llvm/include/llvm/Analysis/LoopAccessAnalysis.h | 2 +- llvm/include/llvm/Analysis/ObjCARCUtil.h | 6 ++--- llvm/include/llvm/Analysis/ScalarEvolution.h | 13 +++++----- llvm/include/llvm/Analysis/ValueTracking.h | 8 +++---- llvm/include/llvm/Bitstream/BitstreamReader.h | 2 +- llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 2 +- llvm/include/llvm/ExecutionEngine/RuntimeDyld.h | 2 +- llvm/include/llvm/IR/ConstantRange.h | 4 ++-- llvm/include/llvm/IR/DebugInfoMetadata.h | 2 +- llvm/include/llvm/IR/GlobalValue.h | 2 +- .../llvm/MC/MCDisassembler/MCDisassembler.h | 4 ++-- llvm/include/llvm/Support/JSON.h | 5 ++-- llvm/include/llvm/Transforms/IPO/Attributor.h | 9 +++---- llvm/lib/Analysis/MemorySSA.cpp | 5 ++-- llvm/lib/Analysis/ProfileSummaryInfo.cpp | 2 +- llvm/lib/Analysis/ScalarEvolution.cpp | 20 ++++++++-------- llvm/lib/Analysis/VFABIDemangling.cpp | 12 +++++----- llvm/lib/Analysis/ValueTracking.cpp | 17 ++++++------- llvm/lib/CodeGen/CodeGenPrepare.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++-- llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp | 3 ++- llvm/lib/Object/MachOObjectFile.cpp | 2 +- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 2 +- llvm/lib/Target/AArch64/AArch64InstrInfo.h | 2 +- .../AArch64/GISel/AArch64InstructionSelector.cpp | 6 ++--- .../Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp | 9 +++---- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 28 +++++++++++----------- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 2 +- llvm/lib/Transforms/IPO/IROutliner.cpp | 2 +- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 2 +- .../lib/Transforms/Instrumentation/MemProfiler.cpp | 2 +- .../lib/Transforms/Scalar/DeadStoreElimination.cpp | 2 +- .../Scalar/InductiveRangeCheckElimination.cpp | 6 ++--- llvm/lib/Transforms/Scalar/LoopPredication.cpp | 3 +-- llvm/lib/Transforms/Utils/ValueMapper.cpp | 13 +++++----- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 4 ++-- llvm/tools/llvm-objdump/llvm-objdump.cpp | 4 ++-- llvm/unittests/IR/MetadataTest.cpp | 2 +- llvm/unittests/Support/DataExtractorTest.cpp | 6 +++-- llvm/utils/TableGen/GlobalISelEmitter.cpp | 2 +- 44 files changed, 123 insertions(+), 116 deletions(-) diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 2e2f9ef..ac9482b 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -2234,7 +2234,7 @@ APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM); /// value to go from [-2^BW, 0) to [0, 2^BW). In that sense, zero is /// treated as a special case of an overflow. /// -/// This function returns None if after finding k that minimizes the +/// This function returns std::nullopt if after finding k that minimizes the /// positive solution to q(n) = kR, both solutions are contained between /// two consecutive integers. /// diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h index f666f52..56c0d9c 100644 --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -293,7 +293,7 @@ public: return has_value() ? value() : std::forward(alt); } - /// Apply a function to the value if present; otherwise return None. + /// Apply a function to the value if present; otherwise return std::nullopt. template auto transform(const Function &F) const & -> Optional { if (*this) @@ -308,7 +308,7 @@ public: return has_value() ? std::move(value()) : std::forward(alt); } - /// Apply a function to the value if present; otherwise return None. + /// Apply a function to the value if present; otherwise return std::nullopt. template auto transform( const Function &F) && -> Optional { diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h index 4bfdda2..d7464b6 100644 --- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h +++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h @@ -888,7 +888,7 @@ public: /// Finds the positive number associated with \p V if it has been mapped. /// \param [in] V - the Value to find. /// \returns The positive number corresponding to the value. - /// \returns None if not present. + /// \returns std::nullopt if not present. Optional getGVN(Value *V) { assert(V != nullptr && "Value is a nullptr?"); DenseMap::iterator VNIt = ValueToNumber.find(V); @@ -900,7 +900,7 @@ public: /// Finds the Value associate with \p Num if it exists. /// \param [in] Num - the number to find. /// \returns The Value associated with the number. - /// \returns None if not present. + /// \returns std::nullopt if not present. Optional fromGVN(unsigned Num) { DenseMap::iterator VNIt = NumberToValue.find(Num); if (VNIt == NumberToValue.end()) diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h index 3f246cc..cef704b 100644 --- a/llvm/include/llvm/Analysis/InlineCost.h +++ b/llvm/include/llvm/Analysis/InlineCost.h @@ -300,8 +300,8 @@ getInlineCost(CallBase &Call, Function *Callee, const InlineParams &Params, /// because of user directives, and the inlining is viable. Returns /// InlineResult::failure() if the inlining may never happen because of user /// directives or incompatibilities detectable without needing callee traversal. -/// Otherwise returns None, meaning that inlining should be decided based on -/// other criteria (e.g. cost modeling). +/// Otherwise returns std::nullopt, meaning that inlining should be decided +/// based on other criteria (e.g. cost modeling). Optional getAttributeBasedInliningDecision( CallBase &Call, Function *Callee, TargetTransformInfo &CalleeTTI, function_ref GetTLI); diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h index c57904e..ee5e3f7 100644 --- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -721,7 +721,7 @@ const SCEV *replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE, Value *Ptr); /// If the pointer has a constant stride return it in units of the access type -/// size. Otherwise return None. +/// size. Otherwise return std::nullopt. /// /// Ensure that it does not wrap in the address space, assuming the predicate /// associated with \p PSE is true. diff --git a/llvm/include/llvm/Analysis/ObjCARCUtil.h b/llvm/include/llvm/Analysis/ObjCARCUtil.h index 913fb3e..7e27e9a 100644 --- a/llvm/include/llvm/Analysis/ObjCARCUtil.h +++ b/llvm/include/llvm/Analysis/ObjCARCUtil.h @@ -54,9 +54,9 @@ inline bool isRetainOrClaimRV(ARCInstKind Kind) { } /// This function returns the ARCInstKind of the function attached to operand -/// bundle clang_arc_attachedcall. It returns None if the call doesn't have the -/// operand bundle or the operand is null. Otherwise it returns either RetainRV -/// or UnsafeClaimRV. +/// bundle clang_arc_attachedcall. It returns std::nullopt if the call doesn't +/// have the operand bundle or the operand is null. Otherwise it returns either +/// RetainRV or UnsafeClaimRV. inline ARCInstKind getAttachedARCFunctionKind(const CallBase *CB) { Optional Fn = getAttachedARCFunction(CB); if (!Fn) diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index a180cf5..6a2dbf7 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1046,7 +1046,7 @@ public: /// Check whether the condition described by Pred, LHS, and RHS is true or /// false. If we know it, return the evaluation of this condition. If neither - /// is proved, return None. + /// is proved, return std::nullopt. Optional evaluatePredicate(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS); @@ -1057,7 +1057,7 @@ public: /// Check whether the condition described by Pred, LHS, and RHS is true or /// false in the given \p Context. If we know it, return the evaluation of - /// this condition. If neither is proved, return None. + /// this condition. If neither is proved, return std::nullopt. Optional evaluatePredicateAt(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI); @@ -1079,7 +1079,8 @@ public: /// If, for all loop invariant X, the predicate "LHS `Pred` X" is /// monotonically increasing or decreasing, returns /// Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing) - /// respectively. If we could not prove either of these facts, returns None. + /// respectively. If we could not prove either of these facts, returns + /// std::nullopt. Optional getMonotonicPredicateType(const SCEVAddRecExpr *LHS, ICmpInst::Predicate Pred); @@ -1095,7 +1096,7 @@ public: }; /// If the result of the predicate LHS `Pred` RHS is loop invariant with /// respect to L, return a LoopInvariantPredicate with LHS and RHS being - /// invariants, available at L's entry. Otherwise, return None. + /// invariants, available at L's entry. Otherwise, return std::nullopt. Optional getLoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L, @@ -1104,8 +1105,8 @@ public: /// If the result of the predicate LHS `Pred` RHS is loop invariant with /// respect to L at given Context during at least first MaxIter iterations, /// return a LoopInvariantPredicate with LHS and RHS being invariants, - /// available at L's entry. Otherwise, return None. The predicate should be - /// the loop's exit condition. + /// available at L's entry. Otherwise, return std::nullopt. The predicate + /// should be the loop's exit condition. Optional getLoopInvariantExitCondDuringFirstIterations(ICmpInst::Predicate Pred, const SCEV *LHS, diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index 8bef592..fa675bb 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -813,10 +813,10 @@ bool matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P, Value *&Start, Value *&Step); /// Return true if RHS is known to be implied true by LHS. Return false if -/// RHS is known to be implied false by LHS. Otherwise, return None if no -/// implication can be made. -/// A & B must be i1 (boolean) values or a vector of such values. Note that -/// the truth table for implication is the same as <=u on i1 values (but not +/// RHS is known to be implied false by LHS. Otherwise, return std::nullopt if +/// no implication can be made. A & B must be i1 (boolean) values or a vector of +/// such values. Note that the truth table for implication is the same as <=u on +/// i1 values (but not /// <=s!). The truth table for both is: /// | T | F (B) /// T | T | F diff --git a/llvm/include/llvm/Bitstream/BitstreamReader.h b/llvm/include/llvm/Bitstream/BitstreamReader.h index 420a9e9..661dc7a 100644 --- a/llvm/include/llvm/Bitstream/BitstreamReader.h +++ b/llvm/include/llvm/Bitstream/BitstreamReader.h @@ -560,7 +560,7 @@ public: Error ReadAbbrevRecord(); /// Read and return a block info block from the bitstream. If an error was - /// encountered, return None. + /// encountered, return std::nullopt. /// /// \param ReadBlockInfoNames Whether to read block/record name information in /// the BlockInfo block. Only llvm-bcanalyzer uses this. diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h index 75d2c6d..213891c 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -369,7 +369,7 @@ public: }; /// \returns The splat index of a G_SHUFFLE_VECTOR \p MI when \p MI is a splat. -/// If \p MI is not a splat, returns None. +/// If \p MI is not a splat, returns std::nullopt. Optional getSplatIndex(MachineInstr &MI); /// \returns the scalar integral splat value of \p Reg if possible. diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h index c434b45..e7895e3 100644 --- a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h +++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h @@ -231,7 +231,7 @@ public: StringRef getSectionContent(unsigned SectionID) const; /// If the section was loaded, return the section's load address, - /// otherwise return None. + /// otherwise return std::nullopt. uint64_t getSectionLoadAddress(unsigned SectionID) const; /// Set the NotifyStubEmitted callback. This is used for debugging diff --git a/llvm/include/llvm/IR/ConstantRange.h b/llvm/include/llvm/IR/ConstantRange.h index d2ff971..4bbc840 100644 --- a/llvm/include/llvm/IR/ConstantRange.h +++ b/llvm/include/llvm/IR/ConstantRange.h @@ -333,11 +333,11 @@ public: PreferredRangeType Type = Smallest) const; /// Intersect the two ranges and return the result if it can be represented - /// exactly, otherwise return None. + /// exactly, otherwise return std::nullopt. Optional exactIntersectWith(const ConstantRange &CR) const; /// Union the two ranges and return the result if it can be represented - /// exactly, otherwise return None. + /// exactly, otherwise return std::nullopt. Optional exactUnionWith(const ConstantRange &CR) const; /// Return a new range representing the possible values resulting diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 9aef251..e6bfea5 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -1728,7 +1728,7 @@ public: /// Returns a new DILocation with updated base discriminator \p BD. Only the /// base discriminator is set in the new DILocation, the other encoded values /// are elided. - /// If the discriminator cannot be encoded, the function returns None. + /// If the discriminator cannot be encoded, the function returns std::nullopt. inline std::optional cloneWithBaseDiscriminator(unsigned BD) const; diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index 0435219..f92e1a3 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -638,7 +638,7 @@ public: bool isAbsoluteSymbolRef() const; /// If this is an absolute symbol reference, returns the range of the symbol, - /// otherwise returns None. + /// otherwise returns std::nullopt. Optional getAbsoluteSymbolRange() const; /// This method unlinks 'this' from the containing module, but does not delete diff --git a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h index 82a1847..55cba3c 100644 --- a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h +++ b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h @@ -141,8 +141,8 @@ public: /// start of a symbol, or the entire symbol. /// This is used for example by WebAssembly to decode preludes. /// - /// Base implementation returns None. So all targets by default ignore to - /// treat symbols separately. + /// Base implementation returns std::nullopt. So all targets by default ignore + /// to treat symbols separately. /// /// \param Symbol - The symbol. /// \param Size - The number of bytes consumed. diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h index 0d07cad..47b2a2f 100644 --- a/llvm/include/llvm/Support/JSON.h +++ b/llvm/include/llvm/Support/JSON.h @@ -135,7 +135,7 @@ public: // Look up a property, returning nullptr if it doesn't exist. Value *get(StringRef K); const Value *get(StringRef K) const; - // Typed accessors return None/nullptr if + // Typed accessors return std::nullopt/nullptr if // - the property doesn't exist // - or it has the wrong type llvm::Optional getNull(StringRef K) const; @@ -400,7 +400,8 @@ public: llvm_unreachable("Unknown kind"); } - // Typed accessors return None/nullptr if the Value is not of this type. + // Typed accessors return std::nullopt/nullptr if the Value is not of this + // type. llvm::Optional getAsNull() const { if (LLVM_LIKELY(Type == T_Null)) return nullptr; diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index 0d02993..648bdd0 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1744,7 +1744,7 @@ struct Attributor { } /// If \p IRP is assumed to be a constant, return it, if it is unclear yet, - /// return None, otherwise return `nullptr`. + /// return std::nullopt, otherwise return `nullptr`. Optional getAssumedConstant(const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation); @@ -1755,7 +1755,7 @@ struct Attributor { } /// If \p V is assumed simplified, return it, if it is unclear yet, - /// return None, otherwise return `nullptr`. + /// return std::nullopt, otherwise return `nullptr`. Optional getAssumedSimplified(const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation, @@ -1771,8 +1771,9 @@ struct Attributor { } /// If \p V is assumed simplified, return it, if it is unclear yet, - /// return None, otherwise return `nullptr`. Same as the public version - /// except that it can be used without recording dependences on any \p AA. + /// return std::nullopt, otherwise return `nullptr`. Same as the public + /// version except that it can be used without recording dependences on any \p + /// AA. Optional getAssumedSimplified(const IRPosition &V, const AbstractAttribute *AA, bool &UsedAssumedInformation, diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp index c308005..c729f0a 100644 --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -621,8 +621,9 @@ template class ClobberWalker { /// value is the indices of searches that stopped at the last phi optimization /// target. It's left in an unspecified state. /// - /// If this returns None, NewPaused is a vector of searches that terminated - /// at StopWhere. Otherwise, NewPaused is left in an unspecified state. + /// If this returns std::nullopt, NewPaused is a vector of searches that + /// terminated at StopWhere. Otherwise, NewPaused is left in an unspecified + /// state. Optional getBlockingAccess(const MemoryAccess *StopWhere, SmallVectorImpl &PausedSearches, diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index 31ee8137..f48698a 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -83,7 +83,7 @@ Optional ProfileSummaryInfo::getProfileCount( // In sample PGO mode, check if there is a profile metadata on the // instruction. If it is present, determine hotness solely based on that, // since the sampled entry count may not be accurate. If there is no - // annotated on the instruction, return None. + // annotated on the instruction, return std::nullopt. uint64_t TotalCount; if (Call.extractProfTotalWeight(TotalCount)) return TotalCount; diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index ad48de1..54542fa 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -712,8 +712,8 @@ CompareValueComplexity(EquivalenceClasses &EqCacheValue, // Return negative, zero, or positive, if LHS is less than, equal to, or greater // than RHS, respectively. A three-way result allows recursive comparisons to be // more efficient. -// If the max analysis depth was reached, return None, assuming we do not know -// if they are equivalent for sure. +// If the max analysis depth was reached, return std::nullopt, assuming we do +// not know if they are equivalent for sure. static std::optional CompareSCEVComplexity(EquivalenceClasses &EqCacheSCEV, EquivalenceClasses &EqCacheValue, @@ -10005,8 +10005,8 @@ static const SCEV *SolveLinEquationWithOverflow(const APInt &A, const SCEV *B, /// Ax^2 + Bx + C is the quadratic function, M is the value that A, B and C /// were multiplied by, and BitWidth is the bit width of the original addrec /// coefficients. -/// This function returns None if the addrec coefficients are not compile- -/// time constants. +/// This function returns std::nullopt if the addrec coefficients are not +/// compile- time constants. static std::optional> GetQuadraticEquation(const SCEVAddRecExpr *AddRec) { assert(AddRec->getNumOperands() == 3 && "This is not a quadratic chrec!"); @@ -10059,7 +10059,7 @@ GetQuadraticEquation(const SCEVAddRecExpr *AddRec) { /// Helper function to compare optional APInts: /// (a) if X and Y both exist, return min(X, Y), -/// (b) if neither X nor Y exist, return None, +/// (b) if neither X nor Y exist, return std::nullopt, /// (c) if exactly one of X and Y exists, return that value. static Optional MinOptional(Optional X, Optional Y) { if (X && Y) { @@ -10102,7 +10102,7 @@ static Optional TruncIfPossible(Optional X, unsigned BitWidth) { /// returned as such, otherwise the bit width of the returned value may /// be greater than BW. /// -/// This function returns None if +/// This function returns std::nullopt if /// (a) the addrec coefficients are not constant, or /// (b) SolveQuadraticEquationWrap was unable to find a solution. For cases /// like x^2 = 5, no integer solutions exist, in other cases an integer @@ -10135,7 +10135,7 @@ SolveQuadraticAddRecExact(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) { /// Find the least n such that c(n) does not belong to the given range, /// while c(n-1) does. /// -/// This function returns None if +/// This function returns std::nullopt if /// (a) the addrec coefficients are not constant, or /// (b) SolveQuadraticEquationWrap was unable to find a solution for the /// bounds of the range. @@ -10196,8 +10196,8 @@ SolveQuadraticAddRecRange(const SCEVAddRecExpr *AddRec, return false; }; - // If SolveQuadraticEquationWrap returns None, it means that there can - // be a solution, but the function failed to find it. We cannot treat it + // If SolveQuadraticEquationWrap returns std::nullopt, it means that there + // can be a solution, but the function failed to find it. We cannot treat it // as "no solution". if (!SO || !UO) return {std::nullopt, false}; @@ -10249,7 +10249,7 @@ SolveQuadraticAddRecRange(const SCEVAddRecExpr *AddRec, // the range before or that we started outside of it. Both of these cases // are contradictions. // - // Claim: In the case where SolveForBoundary returns None, the correct + // Claim: In the case where SolveForBoundary returns std::nullopt, the correct // solution is not some value between the Max for this boundary and the // Min of the other boundary. // diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp index c32ca6a..a076171 100644 --- a/llvm/lib/Analysis/VFABIDemangling.cpp +++ b/llvm/lib/Analysis/VFABIDemangling.cpp @@ -95,7 +95,7 @@ ParseRet tryParseVLEN(StringRef &ParseString, unsigned &VF, bool &IsScalable) { /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `Pos` to /// , and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. /// /// The function expects to be one of "ls", "Rs", "Us" or /// "Ls". @@ -122,7 +122,7 @@ ParseRet tryParseLinearTokenWithRuntimeStep(StringRef &ParseString, /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `StepOrPos` to /// , and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. ParseRet tryParseLinearWithRuntimeStep(StringRef &ParseString, VFParamKind &PKind, int &StepOrPos) { ParseRet Ret; @@ -158,7 +158,7 @@ ParseRet tryParseLinearWithRuntimeStep(StringRef &ParseString, /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `LinearStep` to /// , and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. /// /// The function expects to be one of "l", "R", "U" or /// "L". @@ -186,7 +186,7 @@ ParseRet tryParseCompileTimeLinearToken(StringRef &ParseString, /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `LinearStep` to /// , and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. ParseRet tryParseLinearWithCompileTimeStep(StringRef &ParseString, VFParamKind &PKind, int &StepOrPos) { // "l" {"n"} @@ -219,7 +219,7 @@ ParseRet tryParseLinearWithCompileTimeStep(StringRef &ParseString, /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `StepOrPos` /// accordingly, and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. ParseRet tryParseParameter(StringRef &ParseString, VFParamKind &PKind, int &StepOrPos) { if (ParseString.consume_front("v")) { @@ -254,7 +254,7 @@ ParseRet tryParseParameter(StringRef &ParseString, VFParamKind &PKind, /// On success, it removes the parsed parameter from `ParseString`, /// sets `PKind` to the correspondent enum value, sets `StepOrPos` /// accordingly, and return success. On a syntax error, it return a -/// parsing error. If nothing is parsed, it returns None. +/// parsing error. If nothing is parsed, it returns std::nullopt. ParseRet tryParseAlign(StringRef &ParseString, Align &Alignment) { uint64_t Val; // "a" diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 878177e..2459429 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -2742,7 +2742,7 @@ bool isKnownNonZero(const Value* V, unsigned Depth, const Query& Q) { /// If the pair of operators are the same invertible function, return the /// the operands of the function corresponding to each input. Otherwise, -/// return None. An invertible function is one that is 1-to-1 and maps +/// return std::nullopt. An invertible function is one that is 1-to-1 and maps /// every input value to exactly one output value. This is equivalent to /// saying that Op1 and Op2 are equal exactly when the specified pair of /// operands are equal, (except that Op1 and Op2 may be poison more often.) @@ -6657,7 +6657,7 @@ static bool isTruePredicate(CmpInst::Predicate Pred, const Value *LHS, } /// Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred -/// ALHS ARHS" is true. Otherwise, return None. +/// ALHS ARHS" is true. Otherwise, return std::nullopt. static Optional isImpliedCondOperands(CmpInst::Predicate Pred, const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS, @@ -6694,7 +6694,7 @@ static bool areMatchingOperands(const Value *L0, const Value *L1, const Value *R /// Return true if "icmp1 LPred X, Y" implies "icmp2 RPred X, Y" is true. /// Return false if "icmp1 LPred X, Y" implies "icmp2 RPred X, Y" is false. -/// Otherwise, return None if we can't infer anything. +/// Otherwise, return std::nullopt if we can't infer anything. static Optional isImpliedCondMatchingOperands(CmpInst::Predicate LPred, CmpInst::Predicate RPred, bool AreSwappedOps) { @@ -6712,7 +6712,7 @@ static Optional isImpliedCondMatchingOperands(CmpInst::Predicate LPred, /// Return true if "icmp LPred X, LC" implies "icmp RPred X, RC" is true. /// Return false if "icmp LPred X, LC" implies "icmp RPred X, RC" is false. -/// Otherwise, return None if we can't infer anything. +/// Otherwise, return std::nullopt if we can't infer anything. static Optional isImpliedCondCommonOperandWithConstants( CmpInst::Predicate LPred, const APInt &LC, CmpInst::Predicate RPred, const APInt &RC) { @@ -6728,8 +6728,8 @@ static Optional isImpliedCondCommonOperandWithConstants( } /// Return true if LHS implies RHS (expanded to its components as "R0 RPred R1") -/// is true. Return false if LHS implies RHS is false. Otherwise, return None -/// if we can't infer anything. +/// is true. Return false if LHS implies RHS is false. Otherwise, return +/// std::nullopt if we can't infer anything. static Optional isImpliedCondICmps(const ICmpInst *LHS, CmpInst::Predicate RPred, const Value *R0, const Value *R1, @@ -6761,8 +6761,9 @@ static Optional isImpliedCondICmps(const ICmpInst *LHS, } /// Return true if LHS implies RHS is true. Return false if LHS implies RHS is -/// false. Otherwise, return None if we can't infer anything. We expect the -/// RHS to be an icmp and the LHS to be an 'and', 'or', or a 'select' instruction. +/// false. Otherwise, return std::nullopt if we can't infer anything. We +/// expect the RHS to be an icmp and the LHS to be an 'and', 'or', or a 'select' +/// instruction. static Optional isImpliedCondAndOr(const Instruction *LHS, CmpInst::Predicate RHSPred, const Value *RHSOp0, const Value *RHSOp1, diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 3062c63..e6fea6f 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1433,7 +1433,7 @@ bool matchIncrement(const Instruction *IVInc, Instruction *&LHS, /// If given \p PN is an inductive variable with value IVInc coming from the /// backedge, and on each iteration it gets increased by Step, return pair -/// . Otherwise, return None. +/// . Otherwise, return std::nullopt. static std::optional> getIVIncrement(const PHINode *PN, const LoopInfo *LI) { const Loop *L = LI->getLoopFor(PN->getParent()); diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 3db4dc4..fcaf97d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7892,8 +7892,8 @@ private: /// byte of the given value. Returns None if the provider can't be calculated. /// /// For all the values except the root of the expression, we verify that the -/// value has exactly one use and if not then return None. This way if the -/// origin of the byte is returned it's guaranteed that the values which +/// value has exactly one use and if not then return std::nullopt. This way if +/// the origin of the byte is returned it's guaranteed that the values which /// contribute to the byte are not used outside of this expression. /// However, there is a special case when dealing with vector loads -- we allow diff --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp index 86fa526..a899bba 100644 --- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp +++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp @@ -492,7 +492,8 @@ void MarkupFilter::printValue(Twine Value) { } // This macro helps reduce the amount of indirection done through Optional -// below, since the usual case upon returning a None Optional is to return None. +// below, since the usual case upon returning a std::nullopt Optional is to +// return None. #define ASSIGN_OR_RETURN_NONE(TYPE, NAME, EXPR) \ auto NAME##Opt = (EXPR); \ if (!NAME##Opt) \ diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 92491a0..39e84ff 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -4970,7 +4970,7 @@ MachOObjectFile::getChainedFixupsLoadCommand() const { *DyldChainedFixupsOrErr; // If the load command is present but the data offset has been zeroed out, - // as is the case for dylib stubs, return None (no error). + // as is the case for dylib stubs, return std::nullopt (no error). if (!DyldChainedFixups.dataoff) return std::nullopt; return DyldChainedFixups; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 353692c..6b8bc31 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -1643,7 +1643,7 @@ static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC) { /// \returns Conditions flags used after \p CmpInstr in its MachineBB if NZCV /// flags are not alive in successors of the same \p CmpInstr and \p MI parent. -/// \returns None otherwise. +/// \returns std::nullopt otherwise. /// /// Collect instructions using that flags in \p CCUseInstrs if provided. std::optional diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h index 65792f3..a7402ca 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h @@ -389,7 +389,7 @@ struct UsedNZCV { /// \returns Conditions flags used after \p CmpInstr in its MachineBB if NZCV /// flags are not alive in successors of the same \p CmpInstr and \p MI parent. -/// \returns None otherwise. +/// \returns std::nullopt otherwise. /// /// Collect instructions using that flags in \p CCUseInstrs if provided. std::optional diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 89cb642..a859112 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -5992,7 +5992,7 @@ AArch64InstructionSelector::selectShiftB_64(const MachineOperand &Root) const { /// Helper to select an immediate value that can be represented as a 12-bit /// value shifted left by either 0 or 12. If it is possible to do so, return -/// the immediate and shift value. If not, return None. +/// the immediate and shift value. If not, return std::nullopt. /// /// Used by selectArithImmed and selectNegArithImmed. InstructionSelector::ComplexRendererFns @@ -6251,8 +6251,8 @@ AArch64InstructionSelector::selectAddrModeShiftedExtendXReg( /// /// Where x2 is the base register, and x3 is an offset register. /// -/// When possible (or profitable) to fold a G_PTR_ADD into the address calculation, -/// this will do so. Otherwise, it will return None. +/// When possible (or profitable) to fold a G_PTR_ADD into the address +/// calculation, this will do so. Otherwise, it will return std::nullopt. InstructionSelector::ComplexRendererFns AArch64InstructionSelector::selectAddrModeRegisterOffset( MachineOperand &Root) const { diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp index 741ec22..4428c4f 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp @@ -89,9 +89,9 @@ void PPCELFStreamer::emitInstruction(const MCInst &Inst, static_cast(getAssembler().getEmitterPtr()); // If the instruction is a part of the GOT to PC-Rel link time optimization - // instruction pair, return a value, otherwise return None. A true returned - // value means the instruction is the PLDpc and a false value means it is - // the user instruction. + // instruction pair, return a value, otherwise return std::nullopt. A true + // returned value means the instruction is the PLDpc and a false value means + // it is the user instruction. std::optional IsPartOfGOTToPCRelPair = isPartOfGOTToPCRelPair(Inst, STI); @@ -206,7 +206,8 @@ std::optional llvm::isPartOfGOTToPCRelPair(const MCInst &Inst, unsigned LastOp = Inst.getNumOperands() - 1; // The last operand needs to be an MCExpr and it needs to have a variant kind // of VK_PPC_PCREL_OPT. If it does not satisfy these conditions it is not a - // link time GOT PC Rel opt instruction and we can ignore it and return None. + // link time GOT PC Rel opt instruction and we can ignore it and return + // std::nullopt. const MCOperand &Operand = Inst.getOperand(LastOp); if (!Operand.isExpr()) return std::nullopt; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 7bf4d4a..03f4a56 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -8786,8 +8786,8 @@ struct NodeExtensionHelper { /// anything. Instead they produce an optional CombineResult that if not None, /// need to be materialized for the combine to be applied. /// \see CombineResult::materialize. - /// If the related CombineToTry function returns None, that means the combine - /// didn't match. + /// If the related CombineToTry function returns std::nullopt, that means the + /// combine didn't match. static SmallVector getSupportedFoldings(const SDNode *Root); }; @@ -8835,8 +8835,8 @@ struct CombineResult { /// \note If the pattern can match with both zext and sext, the returned /// CombineResult will feature the zext result. /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVWWithSameExtensionImpl(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS, bool AllowSExt, @@ -8861,8 +8861,8 @@ canFoldToVWWithSameExtensionImpl(SDNode *Root, const NodeExtensionHelper &LHS, /// where `ext` is the same for both LHS and RHS (i.e., both are sext or both /// are zext) and LHS and RHS can be folded into Root. /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVWWithSameExtension(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS) { @@ -8872,8 +8872,8 @@ canFoldToVWWithSameExtension(SDNode *Root, const NodeExtensionHelper &LHS, /// Check if \p Root follows a pattern Root(LHS, ext(RHS)) /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVW_W(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS) { @@ -8897,8 +8897,8 @@ canFoldToVW_W(SDNode *Root, const NodeExtensionHelper &LHS, /// Check if \p Root follows a pattern Root(sext(LHS), sext(RHS)) /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVWWithSEXT(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS) { @@ -8908,8 +8908,8 @@ canFoldToVWWithSEXT(SDNode *Root, const NodeExtensionHelper &LHS, /// Check if \p Root follows a pattern Root(zext(LHS), zext(RHS)) /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVWWithZEXT(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS) { @@ -8919,8 +8919,8 @@ canFoldToVWWithZEXT(SDNode *Root, const NodeExtensionHelper &LHS, /// Check if \p Root follows a pattern Root(sext(LHS), zext(RHS)) /// -/// \returns None if the pattern doesn't match or a CombineResult that can be -/// used to apply the pattern. +/// \returns std::nullopt if the pattern doesn't match or a CombineResult that +/// can be used to apply the pattern. static std::optional canFoldToVW_SU(SDNode *Root, const NodeExtensionHelper &LHS, const NodeExtensionHelper &RHS) { diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 1715460..4ce9611 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -2845,7 +2845,7 @@ private: // - If the value is assumed, then stop. // - If the value is known but undef, then consider it UB. // - Otherwise, do specific processing with the simplified value. - // We return None in the first 2 cases to signify that an appropriate + // We return std::nullopt in the first 2 cases to signify that an appropriate // action was taken and the caller should stop. // Otherwise, we return the simplified value that the caller should // use for specific processing. diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index 1b1d864..d4ff9f6 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -462,7 +462,7 @@ void OutlinableRegion::reattachCandidate() { /// \param GVNToConstant - The mapping of global value number to Constants. /// \returns true if the Value matches the Constant mapped to by V and false if /// it \p V is a Constant but does not match. -/// \returns None if \p V is not a Constant. +/// \returns std::nullopt if \p V is not a Constant. static Optional constantMatches(Value *V, unsigned GVN, DenseMap &GVNToConstant) { diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index a3af1fa..9a7738f 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2484,7 +2484,7 @@ struct AAICVTrackerFunction : public AAICVTracker { return nullptr; } - // We don't check unique value for a function, so return None. + // We don't check unique value for a function, so return std::nullopt. Optional getUniqueReplacementValue(InternalControlVar ICV) const override { return std::nullopt; diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp index e9cf000..6d39c6d 100644 --- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp @@ -171,7 +171,7 @@ public: /// If it is an interesting memory access, populate information /// about the access and return a InterestingMemoryAccess struct. - /// Otherwise return None. + /// Otherwise return std::nullopt. Optional isInterestingMemoryAccess(Instruction *I) const; diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 44d23a1..95a35e3 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -1293,7 +1293,7 @@ struct DSEState { // Find a MemoryDef writing to \p KillingLoc and dominating \p StartAccess, // with no read access between them or on any other path to a function exit // block if \p KillingLoc is not accessible after the function returns. If - // there is no such MemoryDef, return None. The returned value may not + // there is no such MemoryDef, return std::nullopt. The returned value may not // (completely) overwrite \p KillingLoc. Currently we bail out when we // encounter an aliasing MemoryUse (read). Optional diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index a89424c..6e5a415 100644 --- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -1581,7 +1581,7 @@ bool LoopConstrainer::run() { /// Computes and returns a range of values for the induction variable (IndVar) /// in which the range check can be safely elided. If it cannot compute such a -/// range, returns None. +/// range, returns std::nullopt. Optional InductiveRangeCheck::computeSafeIterationSpace( ScalarEvolution &SE, const SCEVAddRecExpr *IndVar, @@ -1733,7 +1733,7 @@ IntersectSignedRange(ScalarEvolution &SE, const SCEV *NewBegin = SE.getSMaxExpr(R1Value.getBegin(), R2.getBegin()); const SCEV *NewEnd = SE.getSMinExpr(R1Value.getEnd(), R2.getEnd()); - // If the resulting range is empty, just return None. + // If the resulting range is empty, just return std::nullopt. auto Ret = InductiveRangeCheck::Range(NewBegin, NewEnd); if (Ret.isEmpty(SE, /* IsSigned */ true)) return std::nullopt; @@ -1762,7 +1762,7 @@ IntersectUnsignedRange(ScalarEvolution &SE, const SCEV *NewBegin = SE.getUMaxExpr(R1Value.getBegin(), R2.getBegin()); const SCEV *NewEnd = SE.getUMinExpr(R1Value.getEnd(), R2.getEnd()); - // If the resulting range is empty, just return None. + // If the resulting range is empty, just return std::nullopt. auto Ret = InductiveRangeCheck::Range(NewBegin, NewEnd); if (Ret.isEmpty(SE, /* IsSigned */ false)) return std::nullopt; diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index a5dddbe..054674d 100644 --- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp @@ -684,10 +684,9 @@ static void normalizePredicate(ScalarEvolution *SE, Loop *L, ICmpInst::ICMP_ULT : ICmpInst::ICMP_UGE; } - /// If ICI can be widened to a loop invariant condition emits the loop /// invariant condition in the loop preheader and return it, otherwise -/// returns None. +/// returns std::nullopt. Optional LoopPredication::widenICmpRangeCheck(ICmpInst *ICI, SCEVExpander &Expander, Instruction *Guard) { diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 3d9fd56..074af66 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -270,8 +270,8 @@ private: /// MDNode, compute and return the mapping. If it's a distinct \a MDNode, /// return the result of \a mapDistinctNode(). /// - /// \return None if \c Op is an unmapped uniqued \a MDNode. - /// \post getMappedOp(Op) only returns None if this returns None. + /// \return std::nullopt if \c Op is an unmapped uniqued \a MDNode. + /// \post getMappedOp(Op) only returns std::nullopt if this returns None. Optional tryToMapOperand(const Metadata *Op); /// Map a distinct node. @@ -317,11 +317,10 @@ private: /// This visits all the nodes in \c G in post-order, using the identity /// mapping or creating a new node depending on \a Data::HasChanged. /// - /// \pre \a getMappedOp() returns None for nodes in \c G, but not for any of - /// their operands outside of \c G. - /// \pre \a Data::HasChanged is true for a node in \c G iff any of its - /// operands have changed. - /// \post \a getMappedOp() returns the mapped node for every node in \c G. + /// \pre \a getMappedOp() returns std::nullopt for nodes in \c G, but not for + /// any of their operands outside of \c G. \pre \a Data::HasChanged is true + /// for a node in \c G iff any of its operands have changed. \post \a + /// getMappedOp() returns the mapped node for every node in \c G. void mapNodesInPOT(UniquedGraph &G); /// Remap a node's operands using the given functor. diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index ea3fac8..27d0b18 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1641,7 +1641,7 @@ public: // Search all operands in Ops[*][Lane] for the one that matches best // Ops[OpIdx][LastLane] and return its opreand index. - // If no good match can be found, return None. + // If no good match can be found, return std::nullopt. Optional getBestOperand(unsigned OpIdx, int Lane, int LastLane, ArrayRef ReorderingModes, ArrayRef MainAltOps) { @@ -1721,7 +1721,7 @@ public: getData(*BestOp.Idx, Lane).IsUsed = IsUsed; return BestOp.Idx; } - // If we could not find a good match return None. + // If we could not find a good match return std::nullopt. return std::nullopt; } diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 565e232..228e094 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1681,8 +1681,8 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj, SectionAddr + Start, CommentStream); if (!Status) { - // If onSymbolStart returns None, that means it didn't trigger any - // interesting handling for this symbol. Try the other symbols + // If onSymbolStart returns std::nullopt, that means it didn't trigger + // any interesting handling for this symbol. Try the other symbols // defined at this address. continue; } diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index bdab1f6..3ffa456 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -1214,7 +1214,7 @@ TEST_F(DILocationTest, discriminatorSpecialCases) { .value() ->getDuplicationFactor()); - // Check we return None for unencodable cases. + // Check we return std::nullopt for unencodable cases. EXPECT_EQ(std::nullopt, L4->cloneWithBaseDiscriminator(0x1000)); EXPECT_EQ(std::nullopt, L4->cloneByMultiplyingDuplicationFactor(0x1000)); } diff --git a/llvm/unittests/Support/DataExtractorTest.cpp b/llvm/unittests/Support/DataExtractorTest.cpp index 358751c..4b240d1 100644 --- a/llvm/unittests/Support/DataExtractorTest.cpp +++ b/llvm/unittests/Support/DataExtractorTest.cpp @@ -344,7 +344,8 @@ TEST(DataExtractorTest, FixedLengthString) { DataExtractor DE(StringRef(Data, sizeof(Data)-1), false, 8); uint64_t Offset = 0; StringRef Str; - // Test extracting too many bytes doesn't modify Offset and returns None. + // Test extracting too many bytes doesn't modify Offset and returns + // std::nullopt. Str = DE.getFixedLengthString(&Offset, sizeof(Data)); EXPECT_TRUE(Str.empty()); EXPECT_EQ(Offset, 0u); @@ -374,7 +375,8 @@ TEST(DataExtractorTest, GetBytes) { DataExtractor DE(Bytes, false, 8); uint64_t Offset = 0; StringRef Str; - // Test extracting too many bytes doesn't modify Offset and returns None. + // Test extracting too many bytes doesn't modify Offset and returns + // std::nullopt. Str = DE.getBytes(&Offset, sizeof(Data)); EXPECT_TRUE(Str.empty()); EXPECT_EQ(Offset, 0u); diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index ecc3e79..d253417 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -3682,7 +3682,7 @@ private: /// Infer a CodeGenRegisterClass for the type of \p SuperRegNode. The returned /// CodeGenRegisterClass will support the CodeGenRegisterClass of /// \p SubRegNode, and the subregister index defined by \p SubRegIdxNode. - /// If no register class is found, return None. + /// If no register class is found, return std::nullopt. Optional inferSuperRegisterClassForNode(const TypeSetByHwMode &Ty, TreePatternNode *SuperRegNode, -- 2.7.4