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