[llvm] 1f421b6 - [llvm] Use std::nullopt instead of None in comments (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 22:45:24 PST 2022
Author: Kazu Hirata
Date: 2022-12-06T22:45:17-08:00
New Revision: 1f421b6d7e4dde37be9ca490175ca4725add762b
URL: https://github.com/llvm/llvm-project/commit/1f421b6d7e4dde37be9ca490175ca4725add762b
DIFF: https://github.com/llvm/llvm-project/commit/1f421b6d7e4dde37be9ca490175ca4725add762b.diff
LOG: [llvm] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/Analysis/BranchProbabilityInfo.h
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/include/llvm/Analysis/Utils/TFUtils.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/GCStrategy.h
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Support/Windows/Threading.inc
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 773c7a85f03ca..c68e8dfbec9e3 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -67,7 +67,7 @@ namespace llvm {
/// Construct an empty ArrayRef.
/*implicit*/ ArrayRef() = default;
- /// Construct an empty ArrayRef from None.
+ /// Construct an empty ArrayRef from std::nullopt.
/*implicit*/ ArrayRef(std::nullopt_t) {}
/// Construct an ArrayRef from a single element.
@@ -320,7 +320,7 @@ namespace llvm {
/// Construct an empty MutableArrayRef.
/*implicit*/ MutableArrayRef() = default;
- /// Construct an empty MutableArrayRef from None.
+ /// Construct an empty MutableArrayRef from std::nullopt.
/*implicit*/ MutableArrayRef(std::nullopt_t) : ArrayRef<T>() {}
/// Construct a MutableArrayRef from a single element.
diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index 66074f445e1ab..0e6e1c774aa49 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -357,7 +357,8 @@ class BranchProbabilityInfo {
void getLoopExitBlocks(const LoopBlock &LB,
SmallVectorImpl<BasicBlock *> &Exits) const;
- /// Returns estimated weight for \p BB. None if \p BB has no estimated weight.
+ /// Returns estimated weight for \p BB. std::nullopt if \p BB has no estimated
+ /// weight.
Optional<uint32_t> getEstimatedBlockWeight(const BasicBlock *BB) const;
/// Returns estimated weight to enter \p L. In other words it is weight of
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index d7464b677b9aa..b663c18991e0d 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -913,8 +913,8 @@ class IRSimilarityCandidate {
/// candidate.
///
/// \param N - The global value number to find the canonical number for.
- /// \returns An optional containing the value, and None if it could not be
- /// found.
+ /// \returns An optional containing the value, and std::nullopt if it could
+ /// not be found.
Optional<unsigned> getCanonicalNum(unsigned N) {
DenseMap<unsigned, unsigned>::iterator NCIt = NumberToCanonNum.find(N);
if (NCIt == NumberToCanonNum.end())
@@ -926,8 +926,8 @@ class IRSimilarityCandidate {
/// candidate.
///
/// \param N - The canonical number to find the global vlaue number for.
- /// \returns An optional containing the value, and None if it could not be
- /// found.
+ /// \returns An optional containing the value, and std::nullopt if it could
+ /// not be found.
Optional<unsigned> fromCanonicalNum(unsigned N) {
DenseMap<unsigned, unsigned>::iterator CNIt = CanonNumToNumber.find(N);
if (CNIt == CanonNumToNumber.end())
diff --git a/llvm/include/llvm/Analysis/Utils/TFUtils.h b/llvm/include/llvm/Analysis/Utils/TFUtils.h
index 7cb72acb80d19..3d74fe619223b 100644
--- a/llvm/include/llvm/Analysis/Utils/TFUtils.h
+++ b/llvm/include/llvm/Analysis/Utils/TFUtils.h
@@ -85,7 +85,7 @@ class TFModelEvaluator final {
/// Evaluate the model, assuming it is valid. Returns std::nullopt if the
/// evaluation fails or the model is invalid, or an EvaluationResult
/// otherwise. The inputs are assumed to have been already provided via
- /// getInput(). When returning None, it also invalidates this object.
+ /// getInput(). When returning std::nullopt, it also invalidates this object.
Optional<EvaluationResult> evaluate();
/// Provides access to the input vector.
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index 6d7c5773379eb..cff13dcf2955f 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -127,7 +127,7 @@ class DWARFAbbreviationDeclaration {
/// attribute.
///
/// \param attr DWARF attribute to search for.
- /// \returns Optional index of the attribute if found, None otherwise.
+ /// \returns Optional index of the attribute if found, std::nullopt otherwise.
std::optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const;
/// Extract a DWARF form value from a DIE specified by DIE offset.
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 8b25395ff653c..f9e11345a739c 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1802,9 +1802,9 @@ class DILocation : public MDNode {
/// \p DF: duplication factor
/// \p CI: copy index
///
- /// The return is None if the values cannot be encoded in 32 bits - for
- /// example, values for BD or DF larger than 12 bits. Otherwise, the return is
- /// the encoded value.
+ /// The return is std::nullopt if the values cannot be encoded in 32 bits -
+ /// for example, values for BD or DF larger than 12 bits. Otherwise, the
+ /// return is the encoded value.
static std::optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF,
unsigned CI);
diff --git a/llvm/include/llvm/IR/GCStrategy.h b/llvm/include/llvm/IR/GCStrategy.h
index 660ac3d479938..8b6cc839bdc6b 100644
--- a/llvm/include/llvm/IR/GCStrategy.h
+++ b/llvm/include/llvm/IR/GCStrategy.h
@@ -92,8 +92,8 @@ class GCStrategy {
/// If the type specified can be reliably distinguished, returns true for
/// pointers to GC managed locations and false for pointers to non-GC
- /// managed locations. Note a GCStrategy can always return 'None' (i.e. an
- /// empty optional indicating it can't reliably distinguish.
+ /// managed locations. Note a GCStrategy can always return 'std::nullopt'
+ /// (i.e. an empty optional indicating it can't reliably distinguish.
virtual std::optional<bool> isGCManagedPointer(const Type *Ty) const {
return std::nullopt;
}
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 94ce2933fd48a..10450157452bc 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -4004,7 +4004,7 @@ struct ValueSimplifyStateType : public AbstractState {
/// Helper to track validity and fixpoint
BooleanState BS;
- /// An assumed simplified value. Initially, it is set to Optional::None, which
+ /// An assumed simplified value. Initially, it is set to std::nullopt, which
/// means that the value is not clear under current assumption. If in the
/// pessimistic state, getAssumedSimplifiedValue doesn't return this value but
/// returns orignal associated value.
@@ -4040,7 +4040,7 @@ struct AAValueSimplify
private:
/// Return an assumed simplified value if a single candidate is found. If
/// there cannot be one, return original value. If it is not clear yet, return
- /// the Optional::NoneType.
+ /// std::nullopt.
///
/// Use `Attributor::getAssumedSimplified` for value simplification.
virtual std::optional<Value *>
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 7dd78deb6edbb..d8caa99ea0bad 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -184,7 +184,7 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
- /// Run either a loop pass or a loop-nest pass. Returns `None` if
+ /// Run either a loop pass or a loop-nest pass. Returns `std::nullopt` if
/// PassInstrumentation's BeforePass returns false. Otherwise, returns the
/// preserved analyses of the pass.
template <typename IRUnitT, typename PassT>
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 546687bbe44ac..25cc7d576c7b5 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5126,7 +5126,7 @@ struct BinaryOp {
} // end anonymous namespace
-/// Try to map \p V into a BinaryOp, and return \c None on failure.
+/// Try to map \p V into a BinaryOp, and return \c std::nullopt on failure.
static std::optional<BinaryOp> MatchBinaryOp(Value *V, const DataLayout &DL,
AssumptionCache &AC,
const DominatorTree &DT,
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 533486a17524b..aaeda2ff85f8f 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -246,8 +246,8 @@ static int computeHostNumHardwareThreads() {
return Threads;
}
-// Finds the proper CPU socket where a thread number should go. Returns 'None'
-// if the thread shall remain on the actual CPU socket.
+// Finds the proper CPU socket where a thread number should go. Returns
+// 'std::nullopt' if the thread shall remain on the actual CPU socket.
std::optional<unsigned>
llvm::ThreadPoolStrategy::compute_cpu_socket(unsigned ThreadPoolNum) const {
ArrayRef<ProcessorGroup> Groups = getProcessorGroups();
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 1d5565ebf815c..5b0f97fff6777 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1766,8 +1766,8 @@ class AAReturnedValuesImpl : public AAReturnedValues, public AbstractState {
}
/// Return an assumed unique return value if a single candidate is found. If
- /// there cannot be one, return a nullptr. If it is not clear yet, return the
- /// Optional::NoneType.
+ /// there cannot be one, return a nullptr. If it is not clear yet, return
+ /// std::nullopt.
std::optional<Value *> getAssumedUniqueReturnValue(Attributor &A) const;
/// See AbstractState::checkForAllReturnedValues(...).
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index b6905ba512c5f..f29ef1661dc6c 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2346,8 +2346,8 @@ struct AAICVTracker : public StateWrapper<BooleanState, AbstractAttribute> {
}
/// Return an assumed unique ICV value if a single candidate is found. If
- /// there cannot be one, return a nullptr. If it is not clear yet, return the
- /// Optional::NoneType.
+ /// there cannot be one, return a nullptr. If it is not clear yet, return
+ /// std::nullopt.
virtual std::optional<Value *>
getUniqueReplacementValue(InternalControlVar ICV) const = 0;
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8aa4f3de3976e..df1fa9df17929 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3255,8 +3255,8 @@ class BoUpSLP {
/// Checks if a bundle of instructions can be scheduled, i.e. has no
/// cyclic dependencies. This is only a dry-run, no instructions are
/// actually moved at this stage.
- /// \returns the scheduling bundle. The returned Optional value is non-None
- /// if \p VL is allowed to be scheduled.
+ /// \returns the scheduling bundle. The returned Optional value is not
+ /// std::nullopt if \p VL is allowed to be scheduled.
Optional<ScheduleData *>
tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
const InstructionsState &S);
More information about the llvm-commits
mailing list