[clang-tools-extra] 7c2b773 - [clang-tools-extra] Use std::nullopt instead of None in comments (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 4 17:40:34 PST 2022


Author: Kazu Hirata
Date: 2022-12-04T17:40:28-08:00
New Revision: 7c2b77368f006f7d4a92b0786adc3f38969d9e2d

URL: https://github.com/llvm/llvm-project/commit/7c2b77368f006f7d4a92b0786adc3f38969d9e2d
DIFF: https://github.com/llvm/llvm-project/commit/7c2b77368f006f7d4a92b0786adc3f38969d9e2d.diff

LOG: [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

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/utils/IncludeSorter.h
    clang-tools-extra/clangd/AST.cpp
    clang-tools-extra/clangd/Headers.h
    clang-tools-extra/clangd/IncludeFixer.h
    clang-tools-extra/clangd/index/dex/PostingList.cpp
    clang-tools-extra/clangd/refactor/Rename.h
    clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
    clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
    clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
    clang-tools-extra/pseudo/lib/DirectiveTree.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
index ecde60de4f9ef..ac76fcd8d7d1e 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h
@@ -44,8 +44,9 @@ class IncludeSorter {
   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:

diff  --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index 92afa98dad025..a0b52ad4813fa 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -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;
 }
 

diff  --git a/clang-tools-extra/clangd/Headers.h b/clang-tools-extra/clangd/Headers.h
index ff3f063168325..72a75de5a0370 100644
--- a/clang-tools-extra/clangd/Headers.h
+++ b/clang-tools-extra/clangd/Headers.h
@@ -238,7 +238,7 @@ class IncludeInserter {
                        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:

diff  --git a/clang-tools-extra/clangd/IncludeFixer.h b/clang-tools-extra/clangd/IncludeFixer.h
index 2bb6c229f4677..0756ee797e851 100644
--- a/clang-tools-extra/clangd/IncludeFixer.h
+++ b/clang-tools-extra/clangd/IncludeFixer.h
@@ -88,7 +88,7 @@ class IncludeFixer {
   // 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;

diff  --git a/clang-tools-extra/clangd/index/dex/PostingList.cpp b/clang-tools-extra/clangd/index/dex/PostingList.cpp
index c1bd338de69d9..06511cfb43bd5 100644
--- a/clang-tools-extra/clangd/index/dex/PostingList.cpp
+++ b/clang-tools-extra/clangd/index/dex/PostingList.cpp
@@ -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;

diff  --git a/clang-tools-extra/clangd/refactor/Rename.h b/clang-tools-extra/clangd/refactor/Rename.h
index 036594e8bebd9..c10aa5a3ad20d 100644
--- a/clang-tools-extra/clangd/refactor/Rename.h
+++ b/clang-tools-extra/clangd/refactor/Rename.h
@@ -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.
 ///

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 93c1e3f007b59..e07a54b2a2845 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -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("::"));

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
index 726e2b87d1400..59885cec05703 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -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) {

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
index ac911be45de96..f704ae464d8e8 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -74,14 +74,14 @@ class LRTable {
 
   // 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()));

diff  --git a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
index 2d0199c630998..b479ecfbbfc1b 100644
--- a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
+++ b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
@@ -45,7 +45,8 @@ class DirectiveParser {
 
   // 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 =


        


More information about the cfe-commits mailing list