Skip to content

Commit 3c09ed0

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 4b7428e commit 3c09ed0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+123
-116
lines changed

llvm/include/llvm/ADT/APInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM);
22342234
/// value to go from [-2^BW, 0) to [0, 2^BW). In that sense, zero is
22352235
/// treated as a special case of an overflow.
22362236
///
2237-
/// This function returns None if after finding k that minimizes the
2237+
/// This function returns std::nullopt if after finding k that minimizes the
22382238
/// positive solution to q(n) = kR, both solutions are contained between
22392239
/// two consecutive integers.
22402240
///

llvm/include/llvm/ADT/Optional.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ template <typename T> class Optional {
293293
return has_value() ? value() : std::forward<U>(alt);
294294
}
295295

296-
/// Apply a function to the value if present; otherwise return None.
296+
/// Apply a function to the value if present; otherwise return std::nullopt.
297297
template <class Function>
298298
auto transform(const Function &F) const & -> Optional<decltype(F(value()))> {
299299
if (*this)
@@ -308,7 +308,7 @@ template <typename T> class Optional {
308308
return has_value() ? std::move(value()) : std::forward<U>(alt);
309309
}
310310

311-
/// Apply a function to the value if present; otherwise return None.
311+
/// Apply a function to the value if present; otherwise return std::nullopt.
312312
template <class Function>
313313
auto transform(
314314
const Function &F) && -> Optional<decltype(F(std::move(*this).value()))> {

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ class IRSimilarityCandidate {
888888
/// Finds the positive number associated with \p V if it has been mapped.
889889
/// \param [in] V - the Value to find.
890890
/// \returns The positive number corresponding to the value.
891-
/// \returns None if not present.
891+
/// \returns std::nullopt if not present.
892892
Optional<unsigned> getGVN(Value *V) {
893893
assert(V != nullptr && "Value is a nullptr?");
894894
DenseMap<Value *, unsigned>::iterator VNIt = ValueToNumber.find(V);
@@ -900,7 +900,7 @@ class IRSimilarityCandidate {
900900
/// Finds the Value associate with \p Num if it exists.
901901
/// \param [in] Num - the number to find.
902902
/// \returns The Value associated with the number.
903-
/// \returns None if not present.
903+
/// \returns std::nullopt if not present.
904904
Optional<Value *> fromGVN(unsigned Num) {
905905
DenseMap<unsigned, Value *>::iterator VNIt = NumberToValue.find(Num);
906906
if (VNIt == NumberToValue.end())

llvm/include/llvm/Analysis/InlineCost.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ getInlineCost(CallBase &Call, Function *Callee, const InlineParams &Params,
300300
/// because of user directives, and the inlining is viable. Returns
301301
/// InlineResult::failure() if the inlining may never happen because of user
302302
/// directives or incompatibilities detectable without needing callee traversal.
303-
/// Otherwise returns None, meaning that inlining should be decided based on
304-
/// other criteria (e.g. cost modeling).
303+
/// Otherwise returns std::nullopt, meaning that inlining should be decided
304+
/// based on other criteria (e.g. cost modeling).
305305
Optional<InlineResult> getAttributeBasedInliningDecision(
306306
CallBase &Call, Function *Callee, TargetTransformInfo &CalleeTTI,
307307
function_ref<const TargetLibraryInfo &(Function &)> GetTLI);

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ const SCEV *replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
721721
Value *Ptr);
722722

723723
/// If the pointer has a constant stride return it in units of the access type
724-
/// size. Otherwise return None.
724+
/// size. Otherwise return std::nullopt.
725725
///
726726
/// Ensure that it does not wrap in the address space, assuming the predicate
727727
/// associated with \p PSE is true.

llvm/include/llvm/Analysis/ObjCARCUtil.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ inline bool isRetainOrClaimRV(ARCInstKind Kind) {
5454
}
5555

5656
/// This function returns the ARCInstKind of the function attached to operand
57-
/// bundle clang_arc_attachedcall. It returns None if the call doesn't have the
58-
/// operand bundle or the operand is null. Otherwise it returns either RetainRV
59-
/// or UnsafeClaimRV.
57+
/// bundle clang_arc_attachedcall. It returns std::nullopt if the call doesn't
58+
/// have the operand bundle or the operand is null. Otherwise it returns either
59+
/// RetainRV or UnsafeClaimRV.
6060
inline ARCInstKind getAttachedARCFunctionKind(const CallBase *CB) {
6161
Optional<Function *> Fn = getAttachedARCFunction(CB);
6262
if (!Fn)

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ class ScalarEvolution {
10461046

10471047
/// Check whether the condition described by Pred, LHS, and RHS is true or
10481048
/// false. If we know it, return the evaluation of this condition. If neither
1049-
/// is proved, return None.
1049+
/// is proved, return std::nullopt.
10501050
Optional<bool> evaluatePredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
10511051
const SCEV *RHS);
10521052

@@ -1057,7 +1057,7 @@ class ScalarEvolution {
10571057

10581058
/// Check whether the condition described by Pred, LHS, and RHS is true or
10591059
/// false in the given \p Context. If we know it, return the evaluation of
1060-
/// this condition. If neither is proved, return None.
1060+
/// this condition. If neither is proved, return std::nullopt.
10611061
Optional<bool> evaluatePredicateAt(ICmpInst::Predicate Pred, const SCEV *LHS,
10621062
const SCEV *RHS, const Instruction *CtxI);
10631063

@@ -1079,7 +1079,8 @@ class ScalarEvolution {
10791079
/// If, for all loop invariant X, the predicate "LHS `Pred` X" is
10801080
/// monotonically increasing or decreasing, returns
10811081
/// Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing)
1082-
/// respectively. If we could not prove either of these facts, returns None.
1082+
/// respectively. If we could not prove either of these facts, returns
1083+
/// std::nullopt.
10831084
Optional<MonotonicPredicateType>
10841085
getMonotonicPredicateType(const SCEVAddRecExpr *LHS,
10851086
ICmpInst::Predicate Pred);
@@ -1095,7 +1096,7 @@ class ScalarEvolution {
10951096
};
10961097
/// If the result of the predicate LHS `Pred` RHS is loop invariant with
10971098
/// respect to L, return a LoopInvariantPredicate with LHS and RHS being
1098-
/// invariants, available at L's entry. Otherwise, return None.
1099+
/// invariants, available at L's entry. Otherwise, return std::nullopt.
10991100
Optional<LoopInvariantPredicate>
11001101
getLoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
11011102
const SCEV *RHS, const Loop *L,
@@ -1104,8 +1105,8 @@ class ScalarEvolution {
11041105
/// If the result of the predicate LHS `Pred` RHS is loop invariant with
11051106
/// respect to L at given Context during at least first MaxIter iterations,
11061107
/// return a LoopInvariantPredicate with LHS and RHS being invariants,
1107-
/// available at L's entry. Otherwise, return None. The predicate should be
1108-
/// the loop's exit condition.
1108+
/// available at L's entry. Otherwise, return std::nullopt. The predicate
1109+
/// should be the loop's exit condition.
11091110
Optional<LoopInvariantPredicate>
11101111
getLoopInvariantExitCondDuringFirstIterations(ICmpInst::Predicate Pred,
11111112
const SCEV *LHS,

llvm/include/llvm/Analysis/ValueTracking.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,10 @@ bool matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P, Value *&Start,
813813
Value *&Step);
814814

815815
/// Return true if RHS is known to be implied true by LHS. Return false if
816-
/// RHS is known to be implied false by LHS. Otherwise, return None if no
817-
/// implication can be made.
818-
/// A & B must be i1 (boolean) values or a vector of such values. Note that
819-
/// the truth table for implication is the same as <=u on i1 values (but not
816+
/// RHS is known to be implied false by LHS. Otherwise, return std::nullopt if
817+
/// no implication can be made. A & B must be i1 (boolean) values or a vector of
818+
/// such values. Note that the truth table for implication is the same as <=u on
819+
/// i1 values (but not
820820
/// <=s!). The truth table for both is:
821821
/// | T | F (B)
822822
/// T | T | F

llvm/include/llvm/Bitstream/BitstreamReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class BitstreamCursor : SimpleBitstreamCursor {
560560
Error ReadAbbrevRecord();
561561

562562
/// Read and return a block info block from the bitstream. If an error was
563-
/// encountered, return None.
563+
/// encountered, return std::nullopt.
564564
///
565565
/// \param ReadBlockInfoNames Whether to read block/record name information in
566566
/// the BlockInfo block. Only llvm-bcanalyzer uses this.

llvm/include/llvm/CodeGen/GlobalISel/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class RegOrConstant {
369369
};
370370

371371
/// \returns The splat index of a G_SHUFFLE_VECTOR \p MI when \p MI is a splat.
372-
/// If \p MI is not a splat, returns None.
372+
/// If \p MI is not a splat, returns std::nullopt.
373373
Optional<int> getSplatIndex(MachineInstr &MI);
374374

375375
/// \returns the scalar integral splat value of \p Reg if possible.

0 commit comments

Comments
 (0)