forked from OSchip/llvm-project
[clang] 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
This commit is contained in:
parent
3dfacc0a56
commit
22731dbd75
|
@ -215,7 +215,8 @@ public:
|
|||
/// Determine the default nullability for properties and methods of this
|
||||
/// class.
|
||||
///
|
||||
/// eturns the default nullability, if implied, or None if there is no
|
||||
/// Returns the default nullability, if implied, or std::nullopt if there is
|
||||
/// none.
|
||||
llvm::Optional<NullabilityKind> getDefaultNullability() const {
|
||||
return HasDefaultNullability
|
||||
? llvm::Optional<NullabilityKind>(
|
||||
|
|
|
@ -183,7 +183,8 @@ namespace clang {
|
|||
llvm::Align getAsAlign() const { return llvm::Align(Quantity); }
|
||||
|
||||
/// getAsMaybeAlign - Returns Quantity as a valid llvm::Align or
|
||||
/// llvm::None, Beware llvm::MaybeAlign assumes power of two 8-bit bytes.
|
||||
/// std::nullopt, Beware llvm::MaybeAlign assumes power of two 8-bit
|
||||
/// bytes.
|
||||
llvm::MaybeAlign getAsMaybeAlign() const {
|
||||
return llvm::MaybeAlign(Quantity);
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ public:
|
|||
/// Returns the \c TraversalKind respected by calls to `match()`, if any.
|
||||
///
|
||||
/// Most matchers will not have a traversal kind set, instead relying on the
|
||||
/// surrounding context. For those, \c llvm::None is returned.
|
||||
/// surrounding context. For those, \c std::nullopt is returned.
|
||||
llvm::Optional<clang::TraversalKind> getTraversalKind() const {
|
||||
return Implementation->TraversalKind();
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ struct TypeErasedDataflowAnalysisState {
|
|||
///
|
||||
/// All predecessors of `Block` except those with loop back edges must have
|
||||
/// already been transferred. States in `BlockStates` that are set to
|
||||
/// `llvm::None` represent basic blocks that are not evaluated yet.
|
||||
/// `std::nullopt` represent basic blocks that are not evaluated yet.
|
||||
TypeErasedDataflowAnalysisState transferBlock(
|
||||
const ControlFlowContext &CFCtx,
|
||||
llvm::ArrayRef<llvm::Optional<TypeErasedDataflowAnalysisState>> BlockStates,
|
||||
|
|
|
@ -719,8 +719,8 @@ private:
|
|||
/// type for functions/methods) @c QT has any of the given attributes,
|
||||
/// provided they pass necessary validation checks AND tracking the given
|
||||
/// attribute is enabled.
|
||||
/// Returns the object kind corresponding to the present attribute, or None,
|
||||
/// if none of the specified attributes are present.
|
||||
/// Returns the object kind corresponding to the present attribute, or
|
||||
/// std::nullopt, if none of the specified attributes are present.
|
||||
/// Crashes if passed an attribute which is not explicitly handled.
|
||||
template <class T>
|
||||
Optional<ObjKind> hasAnyEnabledAttrOf(const Decl *D, QualType QT);
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
|
||||
/// Returns the mapped key, or the appropriate Minimum / MaximumValue if
|
||||
/// they key is outside of the mapping bounds. If they key isn't mapped, but
|
||||
/// within the minimum and maximum bounds, None is returned.
|
||||
/// within the minimum and maximum bounds, std::nullopt is returned.
|
||||
std::optional<VersionTuple>
|
||||
map(const VersionTuple &Key, const VersionTuple &MinimumValue,
|
||||
std::optional<VersionTuple> MaximumValue) const;
|
||||
|
|
|
@ -31,9 +31,9 @@ llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T,
|
|||
llvm::StringRef OffloadArch);
|
||||
|
||||
/// Parse a target ID to get processor and feature map.
|
||||
/// Returns canonicalized processor name or None if the target ID is invalid.
|
||||
/// Returns target ID features in \p FeatureMap if it is not null pointer.
|
||||
/// This function assumes \p OffloadArch is a valid target ID.
|
||||
/// Returns canonicalized processor name or std::nullopt if the target ID is
|
||||
/// invalid. Returns target ID features in \p FeatureMap if it is not null
|
||||
/// pointer. This function assumes \p OffloadArch is a valid target ID.
|
||||
/// If the target ID contains feature+, map it to true.
|
||||
/// If the target ID contains feature-, map it to false.
|
||||
/// If the target ID does not contain a feature (default), do not map it.
|
||||
|
|
|
@ -67,8 +67,8 @@ struct ParsedSourceRange {
|
|||
/// second element is the column.
|
||||
std::pair<unsigned, unsigned> End;
|
||||
|
||||
/// Returns a parsed source range from a string or None if the string is
|
||||
/// invalid.
|
||||
/// Returns a parsed source range from a string or std::nullopt if the string
|
||||
/// is invalid.
|
||||
///
|
||||
/// These source string has the following format:
|
||||
///
|
||||
|
|
|
@ -67,7 +67,8 @@ Nullability getNullabilityAnnotation(QualType Type);
|
|||
|
||||
/// Try to parse the value of a defined preprocessor macro. We can only parse
|
||||
/// simple expressions that consist of an optional minus sign token and then a
|
||||
/// token for an integer. If we cannot parse the value then None is returned.
|
||||
/// token for an integer. If we cannot parse the value then std::nullopt is
|
||||
/// returned.
|
||||
llvm::Optional<int> tryExpandAsInteger(StringRef Macro, const Preprocessor &PP);
|
||||
|
||||
class OperatorKind {
|
||||
|
|
|
@ -204,7 +204,7 @@ public:
|
|||
/// Returns the subrange of spelled tokens corresponding to AST node spanning
|
||||
/// \p Expanded. This is the text that should be replaced if a refactoring
|
||||
/// were to rewrite the node. If \p Expanded is empty, the returned value is
|
||||
/// llvm::None.
|
||||
/// std::nullopt.
|
||||
///
|
||||
/// Will fail if the expanded tokens do not correspond to a sequence of
|
||||
/// spelled tokens. E.g. for the following example:
|
||||
|
|
|
@ -210,7 +210,7 @@ struct AnalysisContext {
|
|||
///
|
||||
/// All predecessors of `Block` except those with loop back edges must have
|
||||
/// already been transferred. States in `AC.BlockStates` that are set to
|
||||
/// `llvm::None` represent basic blocks that are not evaluated yet.
|
||||
/// `std::nullopt` represent basic blocks that are not evaluated yet.
|
||||
static TypeErasedDataflowAnalysisState
|
||||
computeBlockInputState(const CFGBlock &Block, AnalysisContext &AC) {
|
||||
llvm::DenseSet<const CFGBlock *> Preds;
|
||||
|
@ -479,7 +479,7 @@ runTypeErasedDataflowAnalysis(
|
|||
Worklist.enqueueSuccessors(Block);
|
||||
}
|
||||
// FIXME: Consider evaluating unreachable basic blocks (those that have a
|
||||
// state set to `llvm::None` at this point) to also analyze dead code.
|
||||
// state set to `std::nullopt` at this point) to also analyze dead code.
|
||||
|
||||
if (PostVisitCFG) {
|
||||
for (const CFGBlock *Block : CFCtx.getCFG()) {
|
||||
|
|
|
@ -78,7 +78,7 @@ CudaVersion getCudaVersion(uint32_t raw_version) {
|
|||
|
||||
CudaVersion parseCudaHFile(llvm::StringRef Input) {
|
||||
// Helper lambda which skips the words if the line starts with them or returns
|
||||
// None otherwise.
|
||||
// std::nullopt otherwise.
|
||||
auto StartsWithWords =
|
||||
[](llvm::StringRef Line,
|
||||
const SmallVector<StringRef, 3> words) -> std::optional<StringRef> {
|
||||
|
|
|
@ -146,9 +146,9 @@ static bool opensProtoMessageField(const FormatToken &LessTok,
|
|||
(LessTok.Previous && LessTok.Previous->is(tok::equal))));
|
||||
}
|
||||
|
||||
// Returns the delimiter of a raw string literal, or None if TokenText is not
|
||||
// the text of a raw string literal. The delimiter could be the empty string.
|
||||
// For example, the delimiter of R"deli(cont)deli" is deli.
|
||||
// Returns the delimiter of a raw string literal, or std::nullopt if TokenText
|
||||
// is not the text of a raw string literal. The delimiter could be the empty
|
||||
// string. For example, the delimiter of R"deli(cont)deli" is deli.
|
||||
static llvm::Optional<StringRef> getRawStringDelimiter(StringRef TokenText) {
|
||||
if (TokenText.size() < 5 // The smallest raw string possible is 'R"()"'.
|
||||
|| !TokenText.startswith("R\"") || !TokenText.endswith("\"")) {
|
||||
|
|
|
@ -538,7 +538,7 @@ private:
|
|||
/// Dereferences fields up to a given recursion limit.
|
||||
/// Note that \p Vec is passed by value, leading to quadratic copying cost,
|
||||
/// but it's OK in practice since its length is limited to DEREFERENCE_LIMIT.
|
||||
/// \return A chain fields leading to the region of interest or None.
|
||||
/// \return A chain fields leading to the region of interest or std::nullopt.
|
||||
const Optional<RegionVector>
|
||||
findRegionOfInterestInRecord(const RecordDecl *RD, ProgramStateRef State,
|
||||
const MemRegion *R, const RegionVector &Vec = {},
|
||||
|
@ -619,7 +619,7 @@ static bool potentiallyWritesIntoIvar(const Decl *Parent,
|
|||
/// Dereferences fields up to a given recursion limit.
|
||||
/// Note that \p Vec is passed by value, leading to quadratic copying cost,
|
||||
/// but it's OK in practice since its length is limited to DEREFERENCE_LIMIT.
|
||||
/// \return A chain fields leading to the region of interest or None.
|
||||
/// \return A chain fields leading to the region of interest or std::nullopt.
|
||||
const Optional<NoStoreFuncVisitor::RegionVector>
|
||||
NoStoreFuncVisitor::findRegionOfInterestInRecord(
|
||||
const RecordDecl *RD, ProgramStateRef State, const MemRegion *R,
|
||||
|
|
|
@ -2671,8 +2671,8 @@ bool ExprEngine::hasMoreIteration(ProgramStateRef State,
|
|||
}
|
||||
|
||||
/// Split the state on whether there are any more iterations left for this loop.
|
||||
/// Returns a (HasMoreIteration, HasNoMoreIteration) pair, or None when the
|
||||
/// acquisition of the loop condition value failed.
|
||||
/// Returns a (HasMoreIteration, HasNoMoreIteration) pair, or std::nullopt when
|
||||
/// the acquisition of the loop condition value failed.
|
||||
static Optional<std::pair<ProgramStateRef, ProgramStateRef>>
|
||||
assumeCondition(const Stmt *Condition, ExplodedNode *N) {
|
||||
ProgramStateRef State = N->getState();
|
||||
|
|
|
@ -1164,7 +1164,8 @@ template <class SecondTy, class... RestTy>
|
|||
|
||||
/// Main generic intersect function.
|
||||
/// It intersects all of the given range sets. If some of the given arguments
|
||||
/// don't hold a range set (nullptr or llvm::None), the function will skip them.
|
||||
/// don't hold a range set (nullptr or std::nullopt), the function will skip
|
||||
/// them.
|
||||
///
|
||||
/// Available representations for the arguments are:
|
||||
/// * RangeSet
|
||||
|
@ -1179,7 +1180,7 @@ template <class SecondTy, class... RestTy>
|
|||
/// simply RangeSet, in other cases we have to back off to Optional<RangeSet>.
|
||||
///
|
||||
/// Please, prefer optional range sets to raw pointers. If the last argument is
|
||||
/// a raw pointer and all previous arguments are None, it will cost one
|
||||
/// a raw pointer and all previous arguments are std::nullopt, it will cost one
|
||||
/// additional check to convert RangeSet * into Optional<RangeSet>.
|
||||
template <class HeadTy, class SecondTy, class... RestTy>
|
||||
[[nodiscard]] inline
|
||||
|
|
|
@ -46,7 +46,7 @@ struct ParseState {
|
|||
};
|
||||
|
||||
// Represents an intermediate result returned by a parsing function. Functions
|
||||
// that don't generate values should use `llvm::None`
|
||||
// that don't generate values should use `std::nullopt`
|
||||
template <typename ResultType> struct ParseProgress {
|
||||
ParseState State;
|
||||
// Intermediate result generated by the Parser.
|
||||
|
|
Loading…
Reference in New Issue