Skip to content

Commit 1f421b6

Browse files
[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
1 parent 934942c commit 1f421b6

File tree

14 files changed

+27
-26
lines changed

14 files changed

+27
-26
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace llvm {
6767
/// Construct an empty ArrayRef.
6868
/*implicit*/ ArrayRef() = default;
6969

70-
/// Construct an empty ArrayRef from None.
70+
/// Construct an empty ArrayRef from std::nullopt.
7171
/*implicit*/ ArrayRef(std::nullopt_t) {}
7272

7373
/// Construct an ArrayRef from a single element.
@@ -320,7 +320,7 @@ namespace llvm {
320320
/// Construct an empty MutableArrayRef.
321321
/*implicit*/ MutableArrayRef() = default;
322322

323-
/// Construct an empty MutableArrayRef from None.
323+
/// Construct an empty MutableArrayRef from std::nullopt.
324324
/*implicit*/ MutableArrayRef(std::nullopt_t) : ArrayRef<T>() {}
325325

326326
/// Construct a MutableArrayRef from a single element.

llvm/include/llvm/Analysis/BranchProbabilityInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ class BranchProbabilityInfo {
357357
void getLoopExitBlocks(const LoopBlock &LB,
358358
SmallVectorImpl<BasicBlock *> &Exits) const;
359359

360-
/// Returns estimated weight for \p BB. None if \p BB has no estimated weight.
360+
/// Returns estimated weight for \p BB. std::nullopt if \p BB has no estimated
361+
/// weight.
361362
Optional<uint32_t> getEstimatedBlockWeight(const BasicBlock *BB) const;
362363

363364
/// Returns estimated weight to enter \p L. In other words it is weight of

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@ class IRSimilarityCandidate {
913913
/// candidate.
914914
///
915915
/// \param N - The global value number to find the canonical number for.
916-
/// \returns An optional containing the value, and None if it could not be
917-
/// found.
916+
/// \returns An optional containing the value, and std::nullopt if it could
917+
/// not be found.
918918
Optional<unsigned> getCanonicalNum(unsigned N) {
919919
DenseMap<unsigned, unsigned>::iterator NCIt = NumberToCanonNum.find(N);
920920
if (NCIt == NumberToCanonNum.end())
@@ -926,8 +926,8 @@ class IRSimilarityCandidate {
926926
/// candidate.
927927
///
928928
/// \param N - The canonical number to find the global vlaue number for.
929-
/// \returns An optional containing the value, and None if it could not be
930-
/// found.
929+
/// \returns An optional containing the value, and std::nullopt if it could
930+
/// not be found.
931931
Optional<unsigned> fromCanonicalNum(unsigned N) {
932932
DenseMap<unsigned, unsigned>::iterator CNIt = CanonNumToNumber.find(N);
933933
if (CNIt == CanonNumToNumber.end())

llvm/include/llvm/Analysis/Utils/TFUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class TFModelEvaluator final {
8585
/// Evaluate the model, assuming it is valid. Returns std::nullopt if the
8686
/// evaluation fails or the model is invalid, or an EvaluationResult
8787
/// otherwise. The inputs are assumed to have been already provided via
88-
/// getInput(). When returning None, it also invalidates this object.
88+
/// getInput(). When returning std::nullopt, it also invalidates this object.
8989
Optional<EvaluationResult> evaluate();
9090

9191
/// Provides access to the input vector.

llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class DWARFAbbreviationDeclaration {
127127
/// attribute.
128128
///
129129
/// \param attr DWARF attribute to search for.
130-
/// \returns Optional index of the attribute if found, None otherwise.
130+
/// \returns Optional index of the attribute if found, std::nullopt otherwise.
131131
std::optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const;
132132

133133
/// Extract a DWARF form value from a DIE specified by DIE offset.

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,9 +1802,9 @@ class DILocation : public MDNode {
18021802
/// \p DF: duplication factor
18031803
/// \p CI: copy index
18041804
///
1805-
/// The return is None if the values cannot be encoded in 32 bits - for
1806-
/// example, values for BD or DF larger than 12 bits. Otherwise, the return is
1807-
/// the encoded value.
1805+
/// The return is std::nullopt if the values cannot be encoded in 32 bits -
1806+
/// for example, values for BD or DF larger than 12 bits. Otherwise, the
1807+
/// return is the encoded value.
18081808
static std::optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF,
18091809
unsigned CI);
18101810

llvm/include/llvm/IR/GCStrategy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class GCStrategy {
9292

9393
/// If the type specified can be reliably distinguished, returns true for
9494
/// pointers to GC managed locations and false for pointers to non-GC
95-
/// managed locations. Note a GCStrategy can always return 'None' (i.e. an
96-
/// empty optional indicating it can't reliably distinguish.
95+
/// managed locations. Note a GCStrategy can always return 'std::nullopt'
96+
/// (i.e. an empty optional indicating it can't reliably distinguish.
9797
virtual std::optional<bool> isGCManagedPointer(const Type *Ty) const {
9898
return std::nullopt;
9999
}

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,7 +4004,7 @@ struct ValueSimplifyStateType : public AbstractState {
40044004
/// Helper to track validity and fixpoint
40054005
BooleanState BS;
40064006

4007-
/// An assumed simplified value. Initially, it is set to Optional::None, which
4007+
/// An assumed simplified value. Initially, it is set to std::nullopt, which
40084008
/// means that the value is not clear under current assumption. If in the
40094009
/// pessimistic state, getAssumedSimplifiedValue doesn't return this value but
40104010
/// returns orignal associated value.
@@ -4040,7 +4040,7 @@ struct AAValueSimplify
40404040
private:
40414041
/// Return an assumed simplified value if a single candidate is found. If
40424042
/// there cannot be one, return original value. If it is not clear yet, return
4043-
/// the Optional::NoneType.
4043+
/// std::nullopt.
40444044
///
40454045
/// Use `Attributor::getAssumedSimplified` for value simplification.
40464046
virtual std::optional<Value *>

llvm/include/llvm/Transforms/Scalar/LoopPassManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
184184
std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
185185
std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
186186

187-
/// Run either a loop pass or a loop-nest pass. Returns `None` if
187+
/// Run either a loop pass or a loop-nest pass. Returns `std::nullopt` if
188188
/// PassInstrumentation's BeforePass returns false. Otherwise, returns the
189189
/// preserved analyses of the pass.
190190
template <typename IRUnitT, typename PassT>

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5126,7 +5126,7 @@ struct BinaryOp {
51265126

51275127
} // end anonymous namespace
51285128

5129-
/// Try to map \p V into a BinaryOp, and return \c None on failure.
5129+
/// Try to map \p V into a BinaryOp, and return \c std::nullopt on failure.
51305130
static std::optional<BinaryOp> MatchBinaryOp(Value *V, const DataLayout &DL,
51315131
AssumptionCache &AC,
51325132
const DominatorTree &DT,

llvm/lib/Support/Windows/Threading.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ static int computeHostNumHardwareThreads() {
246246
return Threads;
247247
}
248248

249-
// Finds the proper CPU socket where a thread number should go. Returns 'None'
250-
// if the thread shall remain on the actual CPU socket.
249+
// Finds the proper CPU socket where a thread number should go. Returns
250+
// 'std::nullopt' if the thread shall remain on the actual CPU socket.
251251
std::optional<unsigned>
252252
llvm::ThreadPoolStrategy::compute_cpu_socket(unsigned ThreadPoolNum) const {
253253
ArrayRef<ProcessorGroup> Groups = getProcessorGroups();

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,8 +1766,8 @@ class AAReturnedValuesImpl : public AAReturnedValues, public AbstractState {
17661766
}
17671767

17681768
/// Return an assumed unique return value if a single candidate is found. If
1769-
/// there cannot be one, return a nullptr. If it is not clear yet, return the
1770-
/// Optional::NoneType.
1769+
/// there cannot be one, return a nullptr. If it is not clear yet, return
1770+
/// std::nullopt.
17711771
std::optional<Value *> getAssumedUniqueReturnValue(Attributor &A) const;
17721772

17731773
/// See AbstractState::checkForAllReturnedValues(...).

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,8 +2346,8 @@ struct AAICVTracker : public StateWrapper<BooleanState, AbstractAttribute> {
23462346
}
23472347

23482348
/// Return an assumed unique ICV value if a single candidate is found. If
2349-
/// there cannot be one, return a nullptr. If it is not clear yet, return the
2350-
/// Optional::NoneType.
2349+
/// there cannot be one, return a nullptr. If it is not clear yet, return
2350+
/// std::nullopt.
23512351
virtual std::optional<Value *>
23522352
getUniqueReplacementValue(InternalControlVar ICV) const = 0;
23532353

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,8 +3255,8 @@ class BoUpSLP {
32553255
/// Checks if a bundle of instructions can be scheduled, i.e. has no
32563256
/// cyclic dependencies. This is only a dry-run, no instructions are
32573257
/// actually moved at this stage.
3258-
/// \returns the scheduling bundle. The returned Optional value is non-None
3259-
/// if \p VL is allowed to be scheduled.
3258+
/// \returns the scheduling bundle. The returned Optional value is not
3259+
/// std::nullopt if \p VL is allowed to be scheduled.
32603260
Optional<ScheduleData *>
32613261
tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
32623262
const InstructionsState &S);

0 commit comments

Comments
 (0)