[clang-tools-extra] 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:
Kazu Hirata 2022-12-04 17:40:28 -08:00
parent 9f252e5567
commit 7c2b77368f
10 changed files with 15 additions and 13 deletions

View File

@ -44,8 +44,9 @@ public:
void addInclude(StringRef FileName, bool IsAngled,
SourceLocation HashLocation, SourceLocation EndLocation);
/// Creates a quoted inclusion directive in the right sort order. Returns None
/// on error or if header inclusion directive for header already exists.
/// Creates a quoted inclusion directive in the right sort order. Returns
/// std::nullopt on error or if header inclusion directive for header already
/// exists.
Optional<FixItHint> createIncludeInsertion(StringRef FileName, bool IsAngled);
private:

View File

@ -63,8 +63,8 @@ getTemplateSpecializationArgLocs(const NamedDecl &ND) {
if (auto *Args = Var->getTemplateArgsInfo())
return Args->arguments();
}
// We return None for ClassTemplateSpecializationDecls because it does not
// contain TemplateArgumentLoc information.
// We return std::nullopt for ClassTemplateSpecializationDecls because it does
// not contain TemplateArgumentLoc information.
return std::nullopt;
}

View File

@ -238,7 +238,7 @@ public:
llvm::StringRef IncludingFile) const;
/// Calculates an edit that inserts \p VerbatimHeader into code. If the header
/// is already included, this returns None.
/// is already included, this returns std::nullopt.
llvm::Optional<TextEdit> insert(llvm::StringRef VerbatimHeader) const;
private:

View File

@ -88,7 +88,7 @@ private:
// index requests.
mutable llvm::StringMap<SymbolSlab> FuzzyFindCache;
mutable llvm::DenseMap<SymbolID, SymbolSlab> LookupCache;
// Returns None if the number of index requests has reached the limit.
// Returns std::nullopt if the number of index requests has reached the limit.
llvm::Optional<const SymbolSlab *>
fuzzyFindCached(const FuzzyFindRequest &Req) const;
llvm::Optional<const SymbolSlab *> lookupCached(const SymbolID &ID) const;

View File

@ -181,7 +181,7 @@ std::vector<Chunk> encodeStream(llvm::ArrayRef<DocID> Documents) {
}
/// Reads variable length DocID from the buffer and updates the buffer size. If
/// the stream is terminated, return None.
/// the stream is terminated, return std::nullopt.
llvm::Optional<DocID> readVByte(llvm::ArrayRef<uint8_t> &Bytes) {
if (Bytes.front() == 0 || Bytes.empty())
return std::nullopt;

View File

@ -88,7 +88,7 @@ adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier,
std::vector<Range> Indexed, const LangOptions &LangOpts);
/// Calculates the lexed occurrences that the given indexed occurrences map to.
/// Returns None if we don't find a mapping.
/// Returns std::nullopt if we don't find a mapping.
///
/// Exposed for testing only.
///

View File

@ -69,7 +69,7 @@ llvm::Optional<Path> getSourceFile(llvm::StringRef FileName,
// Synthesize a DeclContext for TargetNS from CurContext. TargetNS must be empty
// for global namespace, and endwith "::" otherwise.
// Returns None if TargetNS is not a prefix of CurContext.
// Returns std::nullopt if TargetNS is not a prefix of CurContext.
llvm::Optional<const DeclContext *>
findContextForNS(llvm::StringRef TargetNS, const DeclContext *CurContext) {
assert(TargetNS.empty() || TargetNS.endswith("::"));

View File

@ -59,7 +59,7 @@ llvm::Annotations::Range rangeOrPoint(const llvm::Annotations &A) {
}
// Prepare and apply the specified tweak based on the selection in Input.
// Returns None if and only if prepare() failed.
// Returns std::nullopt if and only if prepare() failed.
llvm::Optional<llvm::Expected<Tweak::Effect>>
applyTweak(ParsedAST &AST, llvm::Annotations::Range Range, StringRef TweakID,
const SymbolIndex *Index, llvm::vfs::FileSystem *FS) {

View File

@ -74,14 +74,14 @@ public:
// Returns the state after we reduce a nonterminal.
// Expected to be called by LR parsers.
// If the nonterminal is invalid here, returns None.
// If the nonterminal is invalid here, returns std::nullopt.
llvm::Optional<StateID> getGoToState(StateID State,
SymbolID Nonterminal) const {
return Gotos.get(gotoIndex(State, Nonterminal, numStates()));
}
// Returns the state after we shift a terminal.
// Expected to be called by LR parsers.
// If the terminal is invalid here, returns None.
// If the terminal is invalid here, returns std::nullopt.
llvm::Optional<StateID> getShiftState(StateID State,
SymbolID Terminal) const {
return Shifts.get(shiftIndex(State, Terminal, numStates()));

View File

@ -45,7 +45,8 @@ private:
// Parses tokens starting at Tok into Tree.
// If we reach an End or Else directive that ends Tree, returns it.
// If TopLevel is true, then we do not expect End and always return None.
// If TopLevel is true, then we do not expect End and always return
// std::nullopt.
llvm::Optional<DirectiveTree::Directive> parse(DirectiveTree *Tree,
bool TopLevel) {
auto StartsDirective =