[clang-tools-extra] 059a23c - [clang-tools-extra] Use std::nullopt instead of None (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 3 11:55:03 PST 2022


Author: Kazu Hirata
Date: 2022-12-03T11:54:50-08:00
New Revision: 059a23c0f01fd6e5bcef0e403d8108a761ad66f5

URL: https://github.com/llvm/llvm-project/commit/059a23c0f01fd6e5bcef0e403d8108a761ad66f5
DIFF: https://github.com/llvm/llvm-project/commit/059a23c0f01fd6e5bcef0e403d8108a761ad66f5.diff

LOG: [clang-tools-extra] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

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-doc/HTMLGenerator.cpp
    clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
    clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
    clang-tools-extra/clang-query/Query.cpp
    clang-tools-extra/clangd/AST.cpp
    clang-tools-extra/clangd/ClangdLSPServer.cpp
    clang-tools-extra/clangd/ClangdServer.cpp
    clang-tools-extra/clangd/ClangdServer.h
    clang-tools-extra/clangd/CodeComplete.cpp
    clang-tools-extra/clangd/CompileCommands.cpp
    clang-tools-extra/clangd/Config.h
    clang-tools-extra/clangd/ConfigCompile.cpp
    clang-tools-extra/clangd/ConfigYAML.cpp
    clang-tools-extra/clangd/Diagnostics.cpp
    clang-tools-extra/clangd/DraftStore.cpp
    clang-tools-extra/clangd/DumpAST.cpp
    clang-tools-extra/clangd/ExpectedTypes.cpp
    clang-tools-extra/clangd/FS.cpp
    clang-tools-extra/clangd/FindSymbols.cpp
    clang-tools-extra/clangd/FuzzyMatch.cpp
    clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
    clang-tools-extra/clangd/GlobalCompilationDatabase.h
    clang-tools-extra/clangd/HeaderSourceSwitch.cpp
    clang-tools-extra/clangd/Headers.cpp
    clang-tools-extra/clangd/Hover.cpp
    clang-tools-extra/clangd/IncludeCleaner.cpp
    clang-tools-extra/clangd/IncludeFixer.cpp
    clang-tools-extra/clangd/InlayHints.cpp
    clang-tools-extra/clangd/ParsedAST.cpp
    clang-tools-extra/clangd/PathMapping.cpp
    clang-tools-extra/clangd/Preamble.cpp
    clang-tools-extra/clangd/Quality.cpp
    clang-tools-extra/clangd/Selection.cpp
    clang-tools-extra/clangd/SemanticHighlighting.cpp
    clang-tools-extra/clangd/SemanticSelection.cpp
    clang-tools-extra/clangd/SourceCode.cpp
    clang-tools-extra/clangd/SourceCode.h
    clang-tools-extra/clangd/SystemIncludeExtractor.cpp
    clang-tools-extra/clangd/TUScheduler.cpp
    clang-tools-extra/clangd/XRefs.cpp
    clang-tools-extra/clangd/index/Background.cpp
    clang-tools-extra/clangd/index/FileIndex.cpp
    clang-tools-extra/clangd/index/IndexAction.cpp
    clang-tools-extra/clangd/index/StdLib.cpp
    clang-tools-extra/clangd/index/SymbolCollector.cpp
    clang-tools-extra/clangd/index/dex/PostingList.cpp
    clang-tools-extra/clangd/refactor/InsertionPoint.cpp
    clang-tools-extra/clangd/refactor/Rename.cpp
    clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
    clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
    clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
    clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
    clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
    clang-tools-extra/clangd/support/FileCache.cpp
    clang-tools-extra/clangd/support/ThreadsafeFS.cpp
    clang-tools-extra/clangd/tool/Check.cpp
    clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
    clang-tools-extra/pseudo/lib/DirectiveTree.cpp
    clang-tools-extra/pseudo/lib/Forest.cpp
    clang-tools-extra/pseudo/lib/grammar/Grammar.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 11a78ba60e35c..03c698cde0459 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -308,7 +308,7 @@ static std::unique_ptr<TagNode> genLink(const Twine &Text, const Twine &Link) {
 
 static std::unique_ptr<HTMLNode>
 genReference(const Reference &Type, StringRef CurrentDirectory,
-             llvm::Optional<StringRef> JumpToSection = None) {
+             llvm::Optional<StringRef> JumpToSection = std::nullopt) {
   if (Type.Path.empty()) {
     if (!JumpToSection)
       return std::make_unique<TextNode>(Type.Name);
@@ -437,7 +437,7 @@ genReferencesBlock(const std::vector<Reference> &References,
 
 static std::unique_ptr<TagNode>
 writeFileDefinition(const Location &L,
-                    llvm::Optional<StringRef> RepositoryUrl = None) {
+                    llvm::Optional<StringRef> RepositoryUrl = std::nullopt) {
   if (!L.IsFileInRootDir || !RepositoryUrl)
     return std::make_unique<TagNode>(
         HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +

diff  --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
index 0f6ebbf2e23b6..f41d478293b90 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
@@ -26,7 +26,7 @@ FindAllMacros::CreateMacroSymbol(const Token &MacroNameTok,
   std::string FilePath =
       getIncludePath(*SM, info->getDefinitionLoc(), Collector);
   if (FilePath.empty())
-    return llvm::None;
+    return std::nullopt;
   return SymbolInfo(MacroNameTok.getIdentifierInfo()->getName(),
                     SymbolInfo::SymbolKind::Macro, FilePath, {});
 }

diff  --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
index e000eae999bde..ccfdb9332c443 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -85,7 +85,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
     Type = SymbolInfo::SymbolKind::EnumDecl;
     // Ignore anonymous enum declarations.
     if (ND->getName().empty())
-      return llvm::None;
+      return std::nullopt;
   } else {
     assert(llvm::isa<RecordDecl>(ND) &&
            "Matched decl must be one of VarDecl, "
@@ -93,7 +93,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
            "EnumDecl and RecordDecl!");
     // C-style record decl can have empty name, e.g "struct { ... } var;".
     if (ND->getName().empty())
-      return llvm::None;
+      return std::nullopt;
     Type = SymbolInfo::SymbolKind::Class;
   }
 
@@ -102,11 +102,12 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
     llvm::errs() << "Declaration " << ND->getDeclName() << "("
                  << ND->getDeclKindName()
                  << ") has invalid declaration location.";
-    return llvm::None;
+    return std::nullopt;
   }
 
   std::string FilePath = getIncludePath(SM, Loc, Collector);
-  if (FilePath.empty()) return llvm::None;
+  if (FilePath.empty())
+    return std::nullopt;
 
   return SymbolInfo(ND->getNameAsString(), Type, FilePath, GetContexts(ND));
 }

diff  --git a/clang-tools-extra/clang-query/Query.cpp b/clang-tools-extra/clang-query/Query.cpp
index 2c169b1f9a7fb..4d62f37231b75 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -121,7 +121,7 @@ void dumpLocations(llvm::raw_ostream &OS, DynTypedNode Node, ASTContext &Ctx,
       continue;
 
     TD.emitDiagnostic(FullSourceLoc(Iter->first, SM), DiagnosticsEngine::Note,
-                      "source locations here", None, None);
+                      "source locations here", std::nullopt, std::nullopt);
 
     Iter = PrintLocations(OS, Iter, Locs.LocationAccessors.end());
     OS << '\n';
@@ -137,10 +137,10 @@ void dumpLocations(llvm::raw_ostream &OS, DynTypedNode Node, ASTContext &Ctx,
         SM.getPresumedLineNumber(Iter->first.getEnd()))
       continue;
 
-    TD.emitDiagnostic(FullSourceLoc(Iter->first.getBegin(), SM),
-                      DiagnosticsEngine::Note,
-                      "source ranges here " + Iter->first.printToString(SM),
-                      CharSourceRange::getTokenRange(Iter->first), None);
+    TD.emitDiagnostic(
+        FullSourceLoc(Iter->first.getBegin(), SM), DiagnosticsEngine::Note,
+        "source ranges here " + Iter->first.printToString(SM),
+        CharSourceRange::getTokenRange(Iter->first), std::nullopt);
 
     Iter = PrintLocations(OS, Iter, Locs.RangeAccessors.end());
   }
@@ -157,7 +157,7 @@ void dumpLocations(llvm::raw_ostream &OS, DynTypedNode Node, ASTContext &Ctx,
     TD.emitDiagnostic(
         FullSourceLoc(Iter->first.getBegin(), SM), DiagnosticsEngine::Note,
         "source range " + Iter->first.printToString(SM) + " starting here...",
-        CharSourceRange::getTokenRange(Iter->first), None);
+        CharSourceRange::getTokenRange(Iter->first), std::nullopt);
 
     auto ColNum = SM.getPresumedColumnNumber(Iter->first.getEnd());
     auto LastLineLoc = Iter->first.getEnd().getLocWithOffset(-(ColNum - 1));
@@ -166,7 +166,7 @@ void dumpLocations(llvm::raw_ostream &OS, DynTypedNode Node, ASTContext &Ctx,
                       DiagnosticsEngine::Note, "... ending here",
                       CharSourceRange::getTokenRange(
                           SourceRange(LastLineLoc, Iter->first.getEnd())),
-                      None);
+                      std::nullopt);
 
     Iter = PrintLocations(OS, Iter, Locs.RangeAccessors.end());
   }
@@ -232,7 +232,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
             TD.emitDiagnostic(
                 FullSourceLoc(R.getBegin(), AST->getSourceManager()),
                 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
-                CharSourceRange::getTokenRange(R), None);
+                CharSourceRange::getTokenRange(R), std::nullopt);
           }
         }
         if (QS.PrintOutput) {

diff  --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index 1773748f24887..92afa98dad025 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -65,7 +65,7 @@ getTemplateSpecializationArgLocs(const NamedDecl &ND) {
   }
   // We return None for ClassTemplateSpecializationDecls because it does not
   // contain TemplateArgumentLoc information.
-  return llvm::None;
+  return std::nullopt;
 }
 
 template <class T>
@@ -571,7 +571,7 @@ llvm::Optional<QualType> getDeducedType(ASTContext &ASTCtx,
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())
-    return llvm::None;
+    return std::nullopt;
   return V.DeducedType;
 }
 
@@ -862,7 +862,7 @@ class ForwardingCallVisitor
         return std::distance(Args.begin(), Begin);
       }
     }
-    return llvm::None;
+    return std::nullopt;
   }
 
   static FunctionDecl *getCalleeDeclOrUniqueOverload(CallExpr *E) {

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 01cd178c5b35c..24280183f0246 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -67,7 +67,7 @@ llvm::Optional<int64_t> decodeVersion(llvm::StringRef Encoded) {
     return Result;
   if (!Encoded.empty()) // Empty can be e.g. diagnostics on close.
     elog("unexpected non-numeric version {0}", Encoded);
-  return llvm::None;
+  return std::nullopt;
 }
 
 const llvm::StringLiteral ApplyFixCommand = "clangd.applyFix";
@@ -808,7 +808,7 @@ void ClangdLSPServer::onWorkspaceSymbol(
 void ClangdLSPServer::onPrepareRename(const TextDocumentPositionParams &Params,
                                       Callback<llvm::Optional<Range>> Reply) {
   Server->prepareRename(
-      Params.textDocument.uri.file(), Params.position, /*NewName*/ llvm::None,
+      Params.textDocument.uri.file(), Params.position, /*NewName*/ std::nullopt,
       Opts.Rename,
       [Reply = std::move(Reply)](llvm::Expected<RenameResult> Result) mutable {
         if (!Result)
@@ -890,7 +890,7 @@ void ClangdLSPServer::onDocumentFormatting(
   auto File = Params.textDocument.uri.file();
   auto Code = Server->getDraft(File);
   Server->formatFile(File,
-                     /*Rng=*/llvm::None,
+                     /*Rng=*/std::nullopt,
                      [Code = std::move(Code), Reply = std::move(Reply)](
                          llvm::Expected<tooling::Replacements> Result) mutable {
                        if (Result)
@@ -951,14 +951,14 @@ void ClangdLSPServer::onFoldingRange(
 static llvm::Optional<Command> asCommand(const CodeAction &Action) {
   Command Cmd;
   if (Action.command && Action.edit)
-    return None; // Not representable. (We never emit these anyway).
+    return std::nullopt; // Not representable. (We never emit these anyway).
   if (Action.command) {
     Cmd = *Action.command;
   } else if (Action.edit) {
     Cmd.command = std::string(ApplyFixCommand);
     Cmd.argument = *Action.edit;
   } else {
-    return None;
+    return std::nullopt;
   }
   Cmd.title = Action.title;
   if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND)
@@ -1153,7 +1153,7 @@ void ClangdLSPServer::onSwitchSourceHeader(
           return Reply(Path.takeError());
         if (*Path)
           return Reply(URIForFile::canonicalize(**Path, Params.uri.file()));
-        return Reply(llvm::None);
+        return Reply(std::nullopt);
       });
 }
 
@@ -1172,7 +1172,7 @@ void ClangdLSPServer::onHover(const TextDocumentPositionParams &Params,
                       if (!H)
                         return Reply(H.takeError());
                       if (!*H)
-                        return Reply(llvm::None);
+                        return Reply(std::nullopt);
 
                       Hover R;
                       R.contents.kind = HoverContentFormat;

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index 5576d60f0f1b7..356d904c2a4af 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -140,7 +140,7 @@ class DraftStoreFS : public ThreadsafeFS {
 private:
   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override {
     auto OFS = llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
-        Base.view(llvm::None));
+        Base.view(std::nullopt));
     OFS->pushOverlay(DirtyFiles.asVFS());
     return OFS;
   }
@@ -515,7 +515,7 @@ void ClangdServer::formatOnType(PathRef File, Position Pos,
                  CB = std::move(CB), this]() mutable {
     auto Style = format::getStyle(format::DefaultFormatStyle, File,
                                   format::DefaultFallbackStyle, Code,
-                                  TFS.view(/*CWD=*/llvm::None).get());
+                                  TFS.view(/*CWD=*/std::nullopt).get());
     if (!Style)
       return CB(Style.takeError());
 
@@ -566,7 +566,7 @@ void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
     if (!InpAST)
       return CB(InpAST.takeError());
     auto R = clangd::rename({Pos, NewName, InpAST->AST, File,
-                             DirtyFS->view(llvm::None), Index, Opts});
+                             DirtyFS->view(std::nullopt), Index, Opts});
     if (!R)
       return CB(R.takeError());
 
@@ -659,7 +659,7 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
                  this](Expected<InputsAndAST> InpAST) mutable {
     if (!InpAST)
       return CB(InpAST.takeError());
-    auto FS = DirtyFS->view(llvm::None);
+    auto FS = DirtyFS->view(std::nullopt);
     auto Selections = tweakSelection(Sel, *InpAST, FS.get());
     if (!Selections)
       return CB(Selections.takeError());
@@ -713,7 +713,7 @@ void ClangdServer::switchSourceHeader(
   //  2) if 1) fails, we use the AST&Index approach, it is slower but supports
   //     
diff erent code layout.
   if (auto CorrespondingFile =
-          getCorrespondingHeaderOrSource(Path, TFS.view(llvm::None)))
+          getCorrespondingHeaderOrSource(Path, TFS.view(std::nullopt)))
     return CB(std::move(CorrespondingFile));
   auto Action = [Path = Path.str(), CB = std::move(CB),
                  this](llvm::Expected<InputsAndAST> InpAST) mutable {
@@ -989,7 +989,7 @@ void ClangdServer::getAST(PathRef File, llvm::Optional<Range> R,
               return false;
             });
         if (!Success)
-          CB(llvm::None);
+          CB(std::nullopt);
       };
   WorkScheduler->runWithAST("GetAST", File, std::move(Action));
 }

diff  --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index 13eed0784c589..11f952fd2c7b1 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -142,7 +142,7 @@ class ClangdServer {
     /// defaults and -resource-dir compiler flag).
     /// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to
     /// obtain the standard resource directory.
-    llvm::Optional<std::string> ResourceDir = llvm::None;
+    llvm::Optional<std::string> ResourceDir = std::nullopt;
 
     /// Time to wait after a new file version before computing diagnostics.
     DebouncePolicy UpdateDebounce = DebouncePolicy{

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index fba4eb1a9ec3f..33088e08387fb 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -258,14 +258,14 @@ struct CompletionCandidate {
   headerToInsertIfAllowed(const CodeCompleteOptions &Opts) const {
     if (Opts.InsertIncludes == CodeCompleteOptions::NeverInsert ||
         RankedIncludeHeaders.empty())
-      return None;
+      return std::nullopt;
     if (SemaResult && SemaResult->Declaration) {
       // Avoid inserting new #include if the declaration is found in the current
       // file e.g. the symbol is forward declared.
       auto &SM = SemaResult->Declaration->getASTContext().getSourceManager();
       for (const Decl *RD : SemaResult->Declaration->redecls())
         if (SM.isInMainFile(SM.getExpansionLoc(RD->getBeginLoc())))
-          return None;
+          return std::nullopt;
     }
     return RankedIncludeHeaders[0];
   }
@@ -1821,7 +1821,7 @@ class CodeCompleteFlow {
          (C.IndexResult &&
           C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) &&
         !C.Name.startswith_insensitive(Filter->pattern()))
-      return None;
+      return std::nullopt;
     return Filter->match(C.Name);
   }
 
@@ -2049,7 +2049,7 @@ maybeFunctionArgumentCommentStart(llvm::StringRef Content) {
   Content = Content.rtrim();
   if (Content.endswith("/*"))
     return Content.size() - 2;
-  return None;
+  return std::nullopt;
 }
 
 CodeCompleteResult codeComplete(PathRef FileName, Position Pos,

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index 2a808b4338b46..e88d92189c1fb 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -42,7 +42,7 @@ llvm::Optional<std::string> queryXcrun(llvm::ArrayRef<llvm::StringRef> Argv) {
   auto Xcrun = llvm::sys::findProgramByName("xcrun");
   if (!Xcrun) {
     log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
-    return llvm::None;
+    return std::nullopt;
   }
   llvm::SmallString<64> OutFile;
   llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
@@ -58,18 +58,18 @@ llvm::Optional<std::string> queryXcrun(llvm::ArrayRef<llvm::StringRef> Argv) {
         "If you have a non-apple toolchain, this is OK. "
         "Otherwise, try xcode-select --install.",
         Ret);
-    return llvm::None;
+    return std::nullopt;
   }
 
   auto Buf = llvm::MemoryBuffer::getFile(OutFile);
   if (!Buf) {
     log("Can't read xcrun output: {0}", Buf.getError().message());
-    return llvm::None;
+    return std::nullopt;
   }
   StringRef Path = Buf->get()->getBuffer().trim();
   if (Path.empty()) {
     log("xcrun produced no output");
-    return llvm::None;
+    return std::nullopt;
   }
   return Path.str();
 }
@@ -120,12 +120,12 @@ std::string detectClangPath() {
 // The effect of this is to set -isysroot correctly. We do the same.
 llvm::Optional<std::string> detectSysroot() {
 #ifndef __APPLE__
-  return llvm::None;
+  return std::nullopt;
 #endif
 
   // SDKROOT overridden in environment, respect it. Driver will set isysroot.
   if (::getenv("SDKROOT"))
-    return llvm::None;
+    return std::nullopt;
   return queryXcrun({"xcrun", "--show-sdk-path"});
 }
 

diff  --git a/clang-tools-extra/clangd/Config.h b/clang-tools-extra/clangd/Config.h
index 9e482fa4bdcda..7de8a7af1373f 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -65,7 +65,7 @@ struct Config {
     std::vector<llvm::unique_function<void(std::vector<std::string> &) const>>
         Edits;
     /// Where to search for compilation databases for this file's flags.
-    CDBSearchSpec CDBSearch = {CDBSearchSpec::Ancestors, llvm::None};
+    CDBSearchSpec CDBSearch = {CDBSearchSpec::Ancestors, std::nullopt};
   } CompileFlags;
 
   enum class BackgroundPolicy { Build, Skip };

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp
index 8f207aba29bf4..a663e5a04f956 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -111,7 +111,7 @@ struct FragmentCompiler {
     std::string RegexError;
     if (!Result.isValid(RegexError)) {
       diag(Error, "Invalid regex " + Anchored + ": " + RegexError, Text.Range);
-      return llvm::None;
+      return std::nullopt;
     }
     return Result;
   }
@@ -129,7 +129,7 @@ struct FragmentCompiler {
                Description)
                .str(),
            Path.Range);
-      return llvm::None;
+      return std::nullopt;
     }
     llvm::SmallString<256> AbsPath = llvm::StringRef(*Path);
     llvm::sys::fs::make_absolute(FragmentDirectory, AbsPath);

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp
index 65e409d025b0a..320f15846e854 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -31,7 +31,7 @@ bestGuess(llvm::StringRef Search,
           llvm::ArrayRef<llvm::StringRef> AllowedValues) {
   unsigned MaxEdit = (Search.size() + 1) / 3;
   if (!MaxEdit)
-    return llvm::None;
+    return std::nullopt;
   llvm::Optional<llvm::StringRef> Result;
   for (const auto &AllowedValue : AllowedValues) {
     unsigned EditDistance = Search.edit_distance(AllowedValue, true, MaxEdit);
@@ -357,7 +357,7 @@ class Parser {
     if (auto *BS = llvm::dyn_cast<BlockScalarNode>(&N))
       return Located<std::string>(BS->getValue().str(), N.getSourceRange());
     warning(Desc + " should be scalar", N);
-    return llvm::None;
+    return std::nullopt;
   }
 
   llvm::Optional<Located<bool>> boolValue(Node &N, llvm::StringRef Desc) {
@@ -366,7 +366,7 @@ class Parser {
         return Located<bool>(*Bool, Scalar->Range);
       warning(Desc + " should be a boolean", N);
     }
-    return llvm::None;
+    return std::nullopt;
   }
 
   // Try to parse a list of single scalar values, or just a single value.
@@ -385,7 +385,7 @@ class Parser {
       }
     } else {
       warning("Expected scalar or list of scalars", N);
-      return llvm::None;
+      return std::nullopt;
     }
     return Result;
   }

diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index c0951edcf5258..a6a0204cf6b78 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -624,7 +624,7 @@ void StoreDiags::BeginSourceFile(const LangOptions &Opts,
 
 void StoreDiags::EndSourceFile() {
   flushLastDiag();
-  LangOpts = None;
+  LangOpts = std::nullopt;
   OrigSrcMgr = nullptr;
 }
 
@@ -925,7 +925,7 @@ llvm::Optional<std::string> getDiagnosticDocURI(Diag::DiagSource Source,
     // '-' in the name.
     std::tie(Module, Check) = Name.split('-');
     if (Module.empty() || Check.empty())
-      return llvm::None;
+      return std::nullopt;
     return ("https://clang.llvm.org/extra/clang-tidy/checks/" + Module + "/" +
             Check + ".html")
         .str();
@@ -939,7 +939,7 @@ llvm::Optional<std::string> getDiagnosticDocURI(Diag::DiagSource Source,
     // However we have no diagnostic codes, which the link should describe!
     break;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/DraftStore.cpp b/clang-tools-extra/clangd/DraftStore.cpp
index 55b4ec59c8e84..8f5b54bc7b21a 100644
--- a/clang-tools-extra/clangd/DraftStore.cpp
+++ b/clang-tools-extra/clangd/DraftStore.cpp
@@ -20,7 +20,7 @@ llvm::Optional<DraftStore::Draft> DraftStore::getDraft(PathRef File) const {
 
   auto It = Drafts.find(File);
   if (It == Drafts.end())
-    return None;
+    return std::nullopt;
 
   return It->second.D;
 }

diff  --git a/clang-tools-extra/clangd/DumpAST.cpp b/clang-tools-extra/clangd/DumpAST.cpp
index 3e2d7ceb2925a..1cf5e4ef8fe92 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -91,7 +91,7 @@ class DumpVisitor : public RecursiveASTVisitor<DumpVisitor> {
     SourceRange SR = getSourceRange(Node);
     auto Spelled = Tokens.spelledForExpanded(Tokens.expandedTokens(SR));
     if (!Spelled)
-      return llvm::None;
+      return std::nullopt;
     return halfOpenToRange(
         Tokens.sourceManager(),
         CharSourceRange::getCharRange(Spelled->front().location(),

diff  --git a/clang-tools-extra/clangd/ExpectedTypes.cpp b/clang-tools-extra/clangd/ExpectedTypes.cpp
index 100aa96e26ccb..8dbad0edbfeb1 100644
--- a/clang-tools-extra/clangd/ExpectedTypes.cpp
+++ b/clang-tools-extra/clangd/ExpectedTypes.cpp
@@ -48,10 +48,10 @@ typeOfCompletion(const CodeCompletionResult &R) {
     D = Template->getTemplatedDecl();
   auto *VD = dyn_cast_or_null<ValueDecl>(D);
   if (!VD)
-    return llvm::None; // We handle only variables and functions below.
+    return std::nullopt; // We handle only variables and functions below.
   auto T = VD->getType();
   if (T.isNull())
-    return llvm::None;
+    return std::nullopt;
   if (auto *FuncT = T->getAs<FunctionType>()) {
     // Functions are a special case. They are completed as 'foo()' and we want
     // to match their return type rather than the function type itself.
@@ -65,13 +65,13 @@ typeOfCompletion(const CodeCompletionResult &R) {
 
 llvm::Optional<OpaqueType> OpaqueType::encode(ASTContext &Ctx, QualType T) {
   if (T.isNull())
-    return None;
+    return std::nullopt;
   const Type *C = toEquivClass(Ctx, T);
   if (!C)
-    return None;
+    return std::nullopt;
   llvm::SmallString<128> Encoded;
   if (index::generateUSRForType(QualType(C, 0), Ctx, Encoded))
-    return None;
+    return std::nullopt;
   return OpaqueType(std::string(Encoded.str()));
 }
 
@@ -87,7 +87,7 @@ OpaqueType::fromCompletionResult(ASTContext &Ctx,
                                  const CodeCompletionResult &R) {
   auto T = typeOfCompletion(R);
   if (!T)
-    return None;
+    return std::nullopt;
   return encode(Ctx, *T);
 }
 

diff  --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp
index 6eea6026d0633..2d7c22df5f503 100644
--- a/clang-tools-extra/clangd/FS.cpp
+++ b/clang-tools-extra/clangd/FS.cpp
@@ -47,7 +47,7 @@ PreambleFileStatusCache::lookup(llvm::StringRef File) const {
   if (I != StatCache.end())
     // Returned Status name should always match the requested File.
     return llvm::vfs::Status::copyWithNewName(I->getValue(), File);
-  return None;
+  return std::nullopt;
 }
 
 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>

diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp
index 2a150e4d854fe..982c57c52e6b8 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -227,7 +227,7 @@ llvm::Optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
   const auto SymbolRange =
       toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!SymbolRange)
-    return llvm::None;
+    return std::nullopt;
 
   index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
   // FIXME: This is not classifying constructors, destructors and operators

diff  --git a/clang-tools-extra/clangd/FuzzyMatch.cpp b/clang-tools-extra/clangd/FuzzyMatch.cpp
index 2a908fd684da3..0e57de7219b03 100644
--- a/clang-tools-extra/clangd/FuzzyMatch.cpp
+++ b/clang-tools-extra/clangd/FuzzyMatch.cpp
@@ -91,14 +91,14 @@ FuzzyMatcher::FuzzyMatcher(llvm::StringRef Pattern)
 
 llvm::Optional<float> FuzzyMatcher::match(llvm::StringRef Word) {
   if (!(WordContainsPattern = init(Word)))
-    return llvm::None;
+    return std::nullopt;
   if (!PatN)
     return 1;
   buildGraph();
   auto Best = std::max(Scores[PatN][WordN][Miss].Score,
                        Scores[PatN][WordN][Match].Score);
   if (isAwful(Best))
-    return llvm::None;
+    return std::nullopt;
   float Score =
       ScoreScale * std::min(PerfectBonus * PatN, std::max<int>(0, Best));
   // If the pattern is as long as the word, we have an exact string match,

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index c1c4897430d9d..e7fbc3c57d3aa 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -185,7 +185,7 @@ class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
     if (CachePopulatedAt > FreshTime)
       return CDB;
 
-    if (/*MayCache=*/load(*TFS.view(/*CWD=*/llvm::None))) {
+    if (/*MayCache=*/load(*TFS.view(/*CWD=*/std::nullopt))) {
       // Use new timestamp, as loading may be slow.
       CachePopulatedAt = stopwatch::now();
       NoCDBAt.store((CDB ? stopwatch::time_point::min() : CachePopulatedAt)
@@ -366,14 +366,14 @@ DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const {
   auto Res = lookupCDB(Req);
   if (!Res) {
     log("Failed to find compilation database for {0}", File);
-    return llvm::None;
+    return std::nullopt;
   }
 
   auto Candidates = Res->CDB->getCompileCommands(File);
   if (!Candidates.empty())
     return std::move(Candidates.front());
 
-  return None;
+  return std::nullopt;
 }
 
 std::vector<DirectoryBasedGlobalCompilationDatabase::DirectoryCache *>
@@ -413,7 +413,7 @@ DirectoryBasedGlobalCompilationDatabase::lookupCDB(
     const auto &Spec = Config::current().CompileFlags.CDBSearch;
     switch (Spec.Policy) {
     case Config::CDBSearchSpec::NoCDBSearch:
-      return llvm::None;
+      return std::nullopt;
     case Config::CDBSearchSpec::FixedDir:
       Storage = *Spec.FixedCDBPath;
       SearchDirs = {Storage};
@@ -444,7 +444,7 @@ DirectoryBasedGlobalCompilationDatabase::lookupCDB(
   }
 
   if (!CDB)
-    return llvm::None;
+    return std::nullopt;
 
   CDBLookupResult Result;
   Result.CDB = std::move(CDB);
@@ -734,7 +734,7 @@ DirectoryBasedGlobalCompilationDatabase::getProjectInfo(PathRef File) const {
       std::chrono::steady_clock::time_point::min();
   auto Res = lookupCDB(Req);
   if (!Res)
-    return llvm::None;
+    return std::nullopt;
   return Res->PI;
 }
 
@@ -756,7 +756,7 @@ OverlayCDB::getCompileCommand(PathRef File) const {
   if (!Cmd)
     Cmd = DelegatingCDB::getCompileCommand(File);
   if (!Cmd)
-    return llvm::None;
+    return std::nullopt;
   if (Mangler)
     Mangler(*Cmd, File);
   return Cmd;
@@ -804,13 +804,13 @@ DelegatingCDB::DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base)
 llvm::Optional<tooling::CompileCommand>
 DelegatingCDB::getCompileCommand(PathRef File) const {
   if (!Base)
-    return llvm::None;
+    return std::nullopt;
   return Base->getCompileCommand(File);
 }
 
 llvm::Optional<ProjectInfo> DelegatingCDB::getProjectInfo(PathRef File) const {
   if (!Base)
-    return llvm::None;
+    return std::nullopt;
   return Base->getProjectInfo(File);
 }
 

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.h b/clang-tools-extra/clangd/GlobalCompilationDatabase.h
index c0d751f82f9bb..5d1b20f562d7a 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.h
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.h
@@ -42,7 +42,7 @@ class GlobalCompilationDatabase {
 
   /// Finds the closest project to \p File.
   virtual llvm::Optional<ProjectInfo> getProjectInfo(PathRef File) const {
-    return llvm::None;
+    return std::nullopt;
   }
 
   /// Makes a guess at how to build a file.

diff  --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
index 039457dff72d6..9221fad77d24e 100644
--- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
@@ -36,7 +36,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(
 
   // We can only switch between the known extensions.
   if (!IsSource && !IsHeader)
-    return None;
+    return std::nullopt;
 
   // Array to lookup extensions for the switch. An opposite of where original
   // extension was found.
@@ -60,7 +60,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(
     if (VFS->exists(NewPath))
       return Path(NewPath);
   }
-  return None;
+  return std::nullopt;
 }
 
 llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
@@ -68,7 +68,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
                                                     const SymbolIndex *Index) {
   if (!Index) {
     // FIXME: use the AST to do the inference.
-    return None;
+    return std::nullopt;
   }
   LookupRequest Request;
   // Find all symbols present in the original file.
@@ -102,7 +102,7 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(PathRef OriginalFile,
   // that the background-index is not finished), we should use the decl/def
   // locations from the AST to do the inference (from .cc to .h).
   if (Candidates.empty())
-    return None;
+    return std::nullopt;
 
   // Pickup the winner, who contains most of symbols.
   // FIXME: should we use other signals (file proximity) to help score?

diff  --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index c808c6f2bcc51..a531197290702 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -242,7 +242,7 @@ IncludeStructure::getID(const FileEntry *Entry) const {
   }
   auto It = UIDToIndex.find(Entry->getUniqueID());
   if (It == UIDToIndex.end())
-    return llvm::None;
+    return std::nullopt;
   return It->second;
 }
 
@@ -336,7 +336,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
   }
   // FIXME: should we allow (some limited number of) "../header.h"?
   if (llvm::sys::path::is_absolute(Suggested))
-    return None;
+    return std::nullopt;
   if (IsSystem)
     Suggested = "<" + Suggested + ">";
   else

diff  --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp
index d3dc3966eca31..e432f17dd485e 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -419,7 +419,7 @@ llvm::Optional<std::string> printExprValue(const Expr *E,
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
       T->isFunctionReferenceType() || T->isVoidType())
-    return llvm::None;
+    return std::nullopt;
 
   Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
@@ -427,7 +427,7 @@ llvm::Optional<std::string> printExprValue(const Expr *E,
       // Disable printing for record-types, as they are usually confusing and
       // might make clang crash while printing the expressions.
       Constant.Val.isStruct() || Constant.Val.isUnion())
-    return llvm::None;
+    return std::nullopt;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
   if (T->isEnumeralType() && Constant.Val.isInt() &&
@@ -468,16 +468,16 @@ llvm::Optional<std::string> printExprValue(const SelectionTree::Node *N,
       break;
     }
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 llvm::Optional<StringRef> fieldName(const Expr *E) {
   const auto *ME = llvm::dyn_cast<MemberExpr>(E->IgnoreCasts());
   if (!ME || !llvm::isa<CXXThisExpr>(ME->getBase()->IgnoreCasts()))
-    return llvm::None;
+    return std::nullopt;
   const auto *Field = llvm::dyn_cast<FieldDecl>(ME->getMemberDecl());
   if (!Field || !Field->getDeclName().isIdentifier())
-    return llvm::None;
+    return std::nullopt;
   return Field->getDeclName().getAsIdentifierInfo()->getName();
 }
 
@@ -485,13 +485,13 @@ llvm::Optional<StringRef> fieldName(const Expr *E) {
 llvm::Optional<StringRef> getterVariableName(const CXXMethodDecl *CMD) {
   assert(CMD->hasBody());
   if (CMD->getNumParams() != 0 || CMD->isVariadic())
-    return llvm::None;
+    return std::nullopt;
   const auto *Body = llvm::dyn_cast<CompoundStmt>(CMD->getBody());
   const auto *OnlyReturn = (Body && Body->size() == 1)
                                ? llvm::dyn_cast<ReturnStmt>(Body->body_front())
                                : nullptr;
   if (!OnlyReturn || !OnlyReturn->getRetValue())
-    return llvm::None;
+    return std::nullopt;
   return fieldName(OnlyReturn->getRetValue());
 }
 
@@ -504,59 +504,59 @@ llvm::Optional<StringRef> getterVariableName(const CXXMethodDecl *CMD) {
 llvm::Optional<StringRef> setterVariableName(const CXXMethodDecl *CMD) {
   assert(CMD->hasBody());
   if (CMD->isConst() || CMD->getNumParams() != 1 || CMD->isVariadic())
-    return llvm::None;
+    return std::nullopt;
   const ParmVarDecl *Arg = CMD->getParamDecl(0);
   if (Arg->isParameterPack())
-    return llvm::None;
+    return std::nullopt;
 
   const auto *Body = llvm::dyn_cast<CompoundStmt>(CMD->getBody());
   if (!Body || Body->size() == 0 || Body->size() > 2)
-    return llvm::None;
+    return std::nullopt;
   // If the second statement exists, it must be `return this` or `return *this`.
   if (Body->size() == 2) {
     auto *Ret = llvm::dyn_cast<ReturnStmt>(Body->body_back());
     if (!Ret || !Ret->getRetValue())
-      return llvm::None;
+      return std::nullopt;
     const Expr *RetVal = Ret->getRetValue()->IgnoreCasts();
     if (const auto *UO = llvm::dyn_cast<UnaryOperator>(RetVal)) {
       if (UO->getOpcode() != UO_Deref)
-        return llvm::None;
+        return std::nullopt;
       RetVal = UO->getSubExpr()->IgnoreCasts();
     }
     if (!llvm::isa<CXXThisExpr>(RetVal))
-      return llvm::None;
+      return std::nullopt;
   }
   // The first statement must be an assignment of the arg to a field.
   const Expr *LHS, *RHS;
   if (const auto *BO = llvm::dyn_cast<BinaryOperator>(Body->body_front())) {
     if (BO->getOpcode() != BO_Assign)
-      return llvm::None;
+      return std::nullopt;
     LHS = BO->getLHS();
     RHS = BO->getRHS();
   } else if (const auto *COCE =
                  llvm::dyn_cast<CXXOperatorCallExpr>(Body->body_front())) {
     if (COCE->getOperator() != OO_Equal || COCE->getNumArgs() != 2)
-      return llvm::None;
+      return std::nullopt;
     LHS = COCE->getArg(0);
     RHS = COCE->getArg(1);
   } else {
-    return llvm::None;
+    return std::nullopt;
   }
 
   // Detect the case when the item is moved into the field.
   if (auto *CE = llvm::dyn_cast<CallExpr>(RHS->IgnoreCasts())) {
     if (CE->getNumArgs() != 1)
-      return llvm::None;
+      return std::nullopt;
     auto *ND = llvm::dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl());
     if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
         !ND->isInStdNamespace())
-      return llvm::None;
+      return std::nullopt;
     RHS = CE->getArg(0);
   }
 
   auto *DRE = llvm::dyn_cast<DeclRefExpr>(RHS->IgnoreCasts());
   if (!DRE || DRE->getDecl() != Arg)
-    return llvm::None;
+    return std::nullopt;
   return fieldName(LHS);
 }
 
@@ -818,7 +818,7 @@ llvm::Optional<HoverInfo> getHoverContents(const Expr *E, ParsedAST &AST,
   // There's not much value in hovering over "42" and getting a hover card
   // saying "42 is an int", similar for other literals.
   if (isLiteral(E))
-    return llvm::None;
+    return std::nullopt;
 
   HoverInfo HI;
   // Print the type and the size for string literals
@@ -837,7 +837,7 @@ llvm::Optional<HoverInfo> getHoverContents(const Expr *E, ParsedAST &AST,
     HI.Name = std::string(getNameForExpr(E));
     return HI;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Generates hover info for attributes.
@@ -1062,13 +1062,13 @@ llvm::Optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
   auto CurLoc = sourceLocationInMainFile(SM, Pos);
   if (!CurLoc) {
     llvm::consumeError(CurLoc.takeError());
-    return llvm::None;
+    return std::nullopt;
   }
   const auto &TB = AST.getTokens();
   auto TokensTouchingCursor = syntax::spelledTokensTouching(*CurLoc, TB);
   // Early exit if there were no tokens around the cursor.
   if (TokensTouchingCursor.empty())
-    return llvm::None;
+    return std::nullopt;
 
   // Show full header file path if cursor is on include directive.
   for (const auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
@@ -1111,7 +1111,7 @@ llvm::Optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
       // If we can't find interesting hover information for this
       // auto/decltype keyword, return nothing to avoid showing
       // irrelevant or incorrect informations.
-      return llvm::None;
+      return std::nullopt;
     }
   }
 
@@ -1146,7 +1146,7 @@ llvm::Optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
   }
 
   if (!HI)
-    return llvm::None;
+    return std::nullopt;
 
   // Reformat Definition
   if (!HI->Definition.empty()) {
@@ -1291,22 +1291,22 @@ llvm::Optional<llvm::StringRef> getBacktickQuoteRange(llvm::StringRef Line,
   llvm::StringRef Prefix = Line.substr(0, Offset);
   constexpr llvm::StringLiteral BeforeStartChars = " \t(=";
   if (!Prefix.empty() && !BeforeStartChars.contains(Prefix.back()))
-    return llvm::None;
+    return std::nullopt;
 
   // The quoted string must be nonempty and usually has no leading/trailing ws.
   auto Next = Line.find('`', Offset + 1);
   if (Next == llvm::StringRef::npos)
-    return llvm::None;
+    return std::nullopt;
   llvm::StringRef Contents = Line.slice(Offset + 1, Next);
   if (Contents.empty() || isWhitespace(Contents.front()) ||
       isWhitespace(Contents.back()))
-    return llvm::None;
+    return std::nullopt;
 
   // The close-quote is usually followed by whitespace or punctuation.
   llvm::StringRef Suffix = Line.substr(Next + 1);
   constexpr llvm::StringLiteral AfterEndChars = " \t)=.,;:";
   if (!Suffix.empty() && !AfterEndChars.contains(Suffix.front()))
-    return llvm::None;
+    return std::nullopt;
 
   return Line.slice(Offset, Next + 1);
 }

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 4e5758547a12e..3cfa52b40a20c 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -392,10 +392,10 @@ ReferencedFiles findReferencedFiles(const ReferencedLocations &Locs,
       [&SM, &CanonIncludes](FileID ID) -> Optional<StringRef> {
         auto Entry = SM.getFileEntryRefForID(ID);
         if (!Entry)
-          return llvm::None;
+          return std::nullopt;
         auto PublicHeader = CanonIncludes.mapHeader(*Entry);
         if (PublicHeader.empty())
-          return llvm::None;
+          return std::nullopt;
         return PublicHeader;
       });
 }

diff  --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp
index fff82a46fc9ce..4332768eff83b 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -58,7 +58,7 @@ llvm::Optional<llvm::StringRef> getArgStr(const clang::Diagnostic &Info,
   case DiagnosticsEngine::ak_std_string:
     return llvm::StringRef(Info.getArgStdStr(Index));
   default:
-    return llvm::None;
+    return std::nullopt;
   }
 }
 
@@ -255,7 +255,7 @@ llvm::Optional<Fix> IncludeFixer::insertHeader(llvm::StringRef Spelled,
   if (auto Edit = Inserter->insert(Spelled))
     F.Edits.push_back(std::move(*Edit));
   else
-    return llvm::None;
+    return std::nullopt;
 
   if (Symbol.empty())
     F.Message = llvm::formatv("Include {0}", Spelled);
@@ -355,7 +355,7 @@ llvm::Optional<std::string> qualifiedByUnresolved(const SourceManager &SM,
     NextLoc = IDTok->getLocation();
   }
   if (Result.empty())
-    return llvm::None;
+    return std::nullopt;
   return Result;
 }
 
@@ -377,10 +377,10 @@ llvm::Optional<std::string> getSpelledSpecifier(const CXXScopeSpec &SS,
     const SourceManager &SM) {
   // Support specifiers written within a single macro argument.
   if (!SM.isWrittenInSameFile(SS.getBeginLoc(), SS.getEndLoc()))
-    return llvm::None;
+    return std::nullopt;
   SourceRange Range(SM.getTopMacroCallerLoc(SS.getBeginLoc()), SM.getTopMacroCallerLoc(SS.getEndLoc()));
   if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
-    return llvm::None;
+    return std::nullopt;
 
   return (toSourceCode(SM, Range) + "::").str();
 }
@@ -418,7 +418,7 @@ llvm::Optional<CheapUnresolvedName> extractUnresolvedNameCheaply(
       } else {
         // We don't fix symbols in scopes that are not top-level e.g. class
         // members, as we don't collect includes for them.
-        return llvm::None;
+        return std::nullopt;
       }
     }
   }
@@ -571,7 +571,7 @@ IncludeFixer::fuzzyFindCached(const FuzzyFindRequest &Req) const {
     return &I->second;
 
   if (IndexRequestCount >= IndexRequestLimit)
-    return llvm::None;
+    return std::nullopt;
   IndexRequestCount++;
 
   SymbolSlab::Builder Matches;
@@ -596,7 +596,7 @@ IncludeFixer::lookupCached(const SymbolID &ID) const {
     return &I->second;
 
   if (IndexRequestCount >= IndexRequestLimit)
-    return llvm::None;
+    return std::nullopt;
   IndexRequestCount++;
 
   // FIXME: consider batching the requests for all diagnostics.

diff  --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp
index 1d13a13521cd1..b4c48f387f97b 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -646,11 +646,11 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
     // TokenBuffer will return null if e.g. R corresponds to only part of a
     // macro expansion.
     if (!Spelled || Spelled->empty())
-      return llvm::None;
+      return std::nullopt;
     // Hint must be within the main file, not e.g. a non-preamble include.
     if (SM.getFileID(Spelled->front().location()) != SM.getMainFileID() ||
         SM.getFileID(Spelled->back().location()) != SM.getMainFileID())
-      return llvm::None;
+      return std::nullopt;
     return Range{sourceLocToPosition(SM, Spelled->front().location()),
                  sourceLocToPosition(SM, Spelled->back().endLocation())};
   }

diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index d42973dacf44d..4e99365facb61 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -399,7 +399,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
     elog("Failed to prepare a compiler instance: {0}",
          !Diags.empty() ? static_cast<DiagBase &>(Diags.back()).Message
                         : "unknown error");
-    return None;
+    return std::nullopt;
   }
   tidy::ClangTidyOptions ClangTidyOpts;
   if (PreserveDiags) {
@@ -443,7 +443,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
   if (!Action->BeginSourceFile(*Clang, MainInput)) {
     log("BeginSourceFile() failed when building AST for {0}",
         MainInput.getFile());
-    return None;
+    return std::nullopt;
   }
   // If we saw an include guard in the preamble section of the main file,
   // mark the main-file as include-guarded.
@@ -784,7 +784,7 @@ ParsedAST::ParsedAST(PathRef TUPath, llvm::StringRef Version,
 
 llvm::Optional<llvm::StringRef> ParsedAST::preambleVersion() const {
   if (!Preamble)
-    return llvm::None;
+    return std::nullopt;
   return llvm::StringRef(Preamble->Version);
 }
 

diff  --git a/clang-tools-extra/clangd/PathMapping.cpp b/clang-tools-extra/clangd/PathMapping.cpp
index 094b0b925a8f8..4120e5d4ae694 100644
--- a/clang-tools-extra/clangd/PathMapping.cpp
+++ b/clang-tools-extra/clangd/PathMapping.cpp
@@ -22,11 +22,11 @@ llvm::Optional<std::string> doPathMapping(llvm::StringRef S,
                                           const PathMappings &Mappings) {
   // Return early to optimize for the common case, wherein S is not a file URI
   if (!S.startswith("file://"))
-    return llvm::None;
+    return std::nullopt;
   auto Uri = URI::parse(S);
   if (!Uri) {
     llvm::consumeError(Uri.takeError());
-    return llvm::None;
+    return std::nullopt;
   }
   for (const auto &Mapping : Mappings) {
     const std::string &From = Dir == PathMapping::Direction::ClientToServer
@@ -42,7 +42,7 @@ llvm::Optional<std::string> doPathMapping(llvm::StringRef S,
           .toString();
     }
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 void applyPathMappings(llvm::json::Value &V, PathMapping::Direction Dir,

diff  --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp
index d2b91894f11b4..649629e199e8d 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -332,7 +332,7 @@ scanPreamble(llvm::StringRef Contents, const tooling::CompileCommand &Cmd) {
       std::move(CI), nullptr, std::move(PreambleContents),
       // Provide an empty FS to prevent preprocessor from performing IO. This
       // also implies missing resolved paths for includes.
-      FS.view(llvm::None), IgnoreDiags);
+      FS.view(std::nullopt), IgnoreDiags);
   if (Clang->getFrontendOpts().Inputs.empty())
     return error("compiler instance had no inputs");
   // We are only interested in main file includes.

diff  --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp
index 182848525a459..a167fc38d0add 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -372,7 +372,7 @@ wordMatching(llvm::StringRef Name, const llvm::StringSet<> *ContextWords) {
     for (const auto &Word : ContextWords->keys())
       if (Name.contains_insensitive(Word))
         return Word;
-  return llvm::None;
+  return std::nullopt;
 }
 
 SymbolRelevanceSignals::DerivedSignals

diff  --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp
index fe09f6a3328d1..754d31c7155b5 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -517,7 +517,7 @@ class SelectionTester {
     // But SourceLocations for a file are numerically contiguous, so we
     // can use cheap integer operations instead.
     if (Loc < SelFileBounds.getBegin() || Loc >= SelFileBounds.getEnd())
-      return llvm::None;
+      return std::nullopt;
     // FIXME: subtracting getRawEncoding() is dubious, move this logic into SM.
     return Loc.getRawEncoding() - SelFileBounds.getBegin().getRawEncoding();
   }

diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index dd25a2f31230c..2d44cba21c146 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -109,7 +109,7 @@ kindForDecl(const NamedDecl *D, const HeuristicResolver *Resolver) {
   if (auto *RD = llvm::dyn_cast<RecordDecl>(D)) {
     // We don't want to highlight lambdas like classes.
     if (RD->isLambda())
-      return llvm::None;
+      return std::nullopt;
     return HighlightingKind::Class;
   }
   if (isa<ClassTemplateDecl, RecordDecl, CXXConstructorDecl, ObjCInterfaceDecl,
@@ -135,7 +135,7 @@ kindForDecl(const NamedDecl *D, const HeuristicResolver *Resolver) {
     return HighlightingKind::Parameter;
   if (auto *VD = dyn_cast<VarDecl>(D)) {
     if (isa<ImplicitParamDecl>(VD)) // e.g. ObjC Self
-      return llvm::None;
+      return std::nullopt;
     return VD->isStaticDataMember()
                ? HighlightingKind::StaticField
                : VD->isLocalVarDecl() ? HighlightingKind::LocalVariable
@@ -162,12 +162,12 @@ kindForDecl(const NamedDecl *D, const HeuristicResolver *Resolver) {
     }
     return HighlightingKind::Unknown;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 llvm::Optional<HighlightingKind>
 kindForType(const Type *TP, const HeuristicResolver *Resolver) {
   if (!TP)
-    return llvm::None;
+    return std::nullopt;
   if (TP->isBuiltinType()) // Builtins are special, they do not have decls.
     return HighlightingKind::Primitive;
   if (auto *TD = dyn_cast<TemplateTypeParmType>(TP))
@@ -176,7 +176,7 @@ kindForType(const Type *TP, const HeuristicResolver *Resolver) {
     return HighlightingKind::Class;
   if (auto *TD = TP->getAsTagDecl())
     return kindForDecl(TD, Resolver);
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Whether T is const in a loose sense - is a variable with this type readonly?
@@ -337,7 +337,7 @@ llvm::Optional<HighlightingToken> resolveConflict(const HighlightingToken &A,
   unsigned Priority1 = evaluateHighlightPriority(A);
   unsigned Priority2 = evaluateHighlightPriority(B);
   if (Priority1 == Priority2 && A.Kind != B.Kind)
-    return llvm::None;
+    return std::nullopt;
   auto Result = Priority1 > Priority2 ? A : B;
   Result.Modifiers = A.Modifiers | B.Modifiers;
   return Result;
@@ -477,7 +477,7 @@ class HighlightingsBuilder {
   llvm::Optional<Range> getRangeForSourceLocation(SourceLocation Loc) {
     Loc = getHighlightableSpellingToken(Loc, SourceMgr);
     if (Loc.isInvalid())
-      return llvm::None;
+      return std::nullopt;
 
     const auto *Tok = TB.spelledTokenAt(Loc);
     assert(Tok);
@@ -517,7 +517,7 @@ llvm::Optional<HighlightingModifier> scopeModifier(const NamedDecl *D) {
   // Some template parameters (e.g. those for variable templates) don't have
   // meaningful DeclContexts. That doesn't mean they're global!
   if (DC->isTranslationUnit() && D->isTemplateParameter())
-    return llvm::None;
+    return std::nullopt;
   // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
   if (D->getLinkageInternal() < ExternalLinkage)
     return HighlightingModifier::FileScope;
@@ -526,14 +526,14 @@ llvm::Optional<HighlightingModifier> scopeModifier(const NamedDecl *D) {
 
 llvm::Optional<HighlightingModifier> scopeModifier(const Type *T) {
   if (!T)
-    return llvm::None;
+    return std::nullopt;
   if (T->isBuiltinType())
     return HighlightingModifier::GlobalScope;
   if (auto *TD = dyn_cast<TemplateTypeParmType>(T))
     return scopeModifier(TD->getDecl());
   if (auto *TD = T->getAsTagDecl())
     return scopeModifier(TD);
-  return llvm::None;
+  return std::nullopt;
 }
 
 /// Produces highlightings, which are not captured by findExplicitReferences,

diff  --git a/clang-tools-extra/clangd/SemanticSelection.cpp b/clang-tools-extra/clangd/SemanticSelection.cpp
index b00f9acf696c2..3541ede75f5c7 100644
--- a/clang-tools-extra/clangd/SemanticSelection.cpp
+++ b/clang-tools-extra/clangd/SemanticSelection.cpp
@@ -48,7 +48,7 @@ llvm::Optional<FoldingRange> toFoldingRange(SourceRange SR,
   // file. Macros have their own FileID so this also checks if locations are not
   // within the macros.
   if ((Begin.first != SM.getMainFileID()) || (End.first != SM.getMainFileID()))
-    return llvm::None;
+    return std::nullopt;
   FoldingRange Range;
   Range.startCharacter = SM.getColumnNumber(Begin.first, Begin.second) - 1;
   Range.startLine = SM.getLineNumber(Begin.first, Begin.second) - 1;
@@ -69,7 +69,7 @@ extractFoldingRange(const syntax::Node *Node,
     const auto *RBrace = cast_or_null<syntax::Leaf>(
         Stmt->findChild(syntax::NodeRole::CloseParen));
     if (!LBrace || !RBrace)
-      return llvm::None;
+      return std::nullopt;
     // Fold the entire range within braces, including whitespace.
     const SourceLocation LBraceLocInfo =
                              TM.getToken(LBrace->getTokenKey())->endLocation(),
@@ -82,7 +82,7 @@ extractFoldingRange(const syntax::Node *Node,
     if (Range && Range->startLine != Range->endLine)
       return Range;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Traverse the tree and collect folding ranges along the way.

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp
index d51bb997b5305..6a783c61e245d 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -427,11 +427,11 @@ llvm::Optional<SourceRange> toHalfOpenFileRange(const SourceManager &SM,
                                                 SourceRange R) {
   SourceRange R1 = getTokenFileRange(R.getBegin(), SM, LangOpts);
   if (!isValidFileRange(SM, R1))
-    return llvm::None;
+    return std::nullopt;
 
   SourceRange R2 = getTokenFileRange(R.getEnd(), SM, LangOpts);
   if (!isValidFileRange(SM, R2))
-    return llvm::None;
+    return std::nullopt;
 
   SourceRange Result =
       rangeInCommonFile(unionTokenRange(R1, R2, SM, LangOpts), SM, LangOpts);
@@ -439,7 +439,7 @@ llvm::Optional<SourceRange> toHalfOpenFileRange(const SourceManager &SM,
   // Convert from closed token range to half-open (char) range
   Result.setEnd(Result.getEnd().getLocWithOffset(TokLen));
   if (!isValidFileRange(SM, Result))
-    return llvm::None;
+    return std::nullopt;
 
   return Result;
 }
@@ -515,7 +515,7 @@ std::vector<TextEdit> replacementsToEdits(llvm::StringRef Code,
 llvm::Optional<std::string> getCanonicalPath(const FileEntry *F,
                                              const SourceManager &SourceMgr) {
   if (!F)
-    return None;
+    return std::nullopt;
 
   llvm::SmallString<128> FilePath = F->getName();
   if (!llvm::sys::path::is_absolute(FilePath)) {
@@ -524,7 +524,7 @@ llvm::Optional<std::string> getCanonicalPath(const FileEntry *F,
                 FilePath)) {
       elog("Could not turn relative path '{0}' to absolute: {1}", FilePath,
            EC.message());
-      return None;
+      return std::nullopt;
     }
   }
 
@@ -574,7 +574,7 @@ llvm::Optional<FileDigest> digestFile(const SourceManager &SM, FileID FID) {
   bool Invalid = false;
   llvm::StringRef Content = SM.getBufferData(FID, &Invalid);
   if (Invalid)
-    return None;
+    return std::nullopt;
   return digest(Content);
 }
 
@@ -583,7 +583,7 @@ format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
                                           const ThreadsafeFS &TFS) {
   auto Style = format::getStyle(format::DefaultFormatStyle, File,
                                 format::DefaultFallbackStyle, Content,
-                                TFS.view(/*CWD=*/llvm::None).get());
+                                TFS.view(/*CWD=*/std::nullopt).get());
   if (!Style) {
     log("getStyle() failed for file {0}: {1}. Fallback is LLVM style.", File,
         Style.takeError());
@@ -951,14 +951,14 @@ llvm::Optional<SpelledWord> SpelledWord::touching(SourceLocation SpelledLoc,
   bool Invalid = false;
   llvm::StringRef Code = SM.getBufferData(File, &Invalid);
   if (Invalid)
-    return llvm::None;
+    return std::nullopt;
   unsigned B = Offset, E = Offset;
   while (B > 0 && isAsciiIdentifierContinue(Code[B - 1]))
     --B;
   while (E < Code.size() && isAsciiIdentifierContinue(Code[E]))
     ++E;
   if (B == E)
-    return llvm::None;
+    return std::nullopt;
 
   SpelledWord Result;
   Result.Location = SM.getComposedLoc(File, B);
@@ -977,13 +977,13 @@ llvm::Optional<SpelledWord> SpelledWord::touching(SourceLocation SpelledLoc,
 llvm::Optional<DefinedMacro> locateMacroAt(const syntax::Token &SpelledTok,
                                            Preprocessor &PP) {
   if (SpelledTok.kind() != tok::identifier)
-    return None;
+    return std::nullopt;
   SourceLocation Loc = SpelledTok.location();
   assert(Loc.isFileID());
   const auto &SM = PP.getSourceManager();
   IdentifierInfo *IdentifierInfo = PP.getIdentifierInfo(SpelledTok.text(SM));
   if (!IdentifierInfo || !IdentifierInfo->hadMacroDefinition())
-    return None;
+    return std::nullopt;
 
   // We need to take special case to handle #define and #undef.
   // Preprocessor::getMacroDefinitionAtLoc() only considers a macro
@@ -1004,7 +1004,7 @@ llvm::Optional<DefinedMacro> locateMacroAt(const syntax::Token &SpelledTok,
                     .getMacroInfo();
   }
   if (!MacroInfo) {
-    return None;
+    return std::nullopt;
   }
   return DefinedMacro{
       IdentifierInfo->getName(), MacroInfo,

diff  --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h
index 70d1ebe9b0990..fa4e03b9f2e5a 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -320,7 +320,7 @@ llvm::Optional<DefinedMacro> locateMacroAt(const syntax::Token &SpelledTok,
 /// Infers whether this is a header from the FileName and LangOpts (if
 /// presents).
 bool isHeaderFile(llvm::StringRef FileName,
-                  llvm::Optional<LangOptions> LangOpts = llvm::None);
+                  llvm::Optional<LangOptions> LangOpts = std::nullopt);
 
 /// Returns true if the given location is in a generated protobuf file.
 bool isProtoFile(SourceLocation Loc, const SourceManager &SourceMgr);

diff  --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
index 2624b8fafcfc6..b65902bd4256b 100644
--- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -126,11 +126,11 @@ llvm::Optional<DriverInfo> parseDriverOutput(llvm::StringRef Output) {
   }
   if (!SeenIncludes) {
     elog("System include extraction: start marker not found: {0}", Output);
-    return llvm::None;
+    return std::nullopt;
   }
   if (State == IncludesExtracting) {
     elog("System include extraction: end marker missing: {0}", Output);
-    return llvm::None;
+    return std::nullopt;
   }
   return std::move(Info);
 }
@@ -152,7 +152,7 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
       Driver = *DriverProgram;
     } else {
       elog("System include extraction: driver {0} not found in PATH", Driver);
-      return llvm::None;
+      return std::nullopt;
     }
   }
 
@@ -161,7 +161,7 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
 
   if (!QueryDriverRegex.match(Driver)) {
     vlog("System include extraction: not allowed driver {0}", Driver);
-    return llvm::None;
+    return std::nullopt;
   }
 
   llvm::SmallString<128> StdErrPath;
@@ -170,7 +170,7 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
     elog("System include extraction: failed to create temporary file with "
          "error {0}",
          EC.message());
-    return llvm::None;
+    return std::nullopt;
   }
   auto CleanUp = llvm::make_scope_exit(
       [&StdErrPath]() { llvm::sys::fs::remove(StdErrPath); });
@@ -209,26 +209,26 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
   }
 
   std::string ErrMsg;
-  if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
+  if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/std::nullopt,
                                          Redirects, /*SecondsToWait=*/0,
                                          /*MemoryLimit=*/0, &ErrMsg)) {
     elog("System include extraction: driver execution failed with return code: "
          "{0} - '{1}'. Args: [{2}]",
          llvm::to_string(RC), ErrMsg, printArgv(Args));
-    return llvm::None;
+    return std::nullopt;
   }
 
   auto BufOrError = llvm::MemoryBuffer::getFile(StdErrPath);
   if (!BufOrError) {
     elog("System include extraction: failed to read {0} with error {1}",
          StdErrPath, BufOrError.getError().message());
-    return llvm::None;
+    return std::nullopt;
   }
 
   llvm::Optional<DriverInfo> Info =
       parseDriverOutput(BufOrError->get()->getBuffer());
   if (!Info)
-    return llvm::None;
+    return std::nullopt;
   log("System includes extractor: successfully executed {0}\n\tgot includes: "
       "\"{1}\"\n\tgot target: \"{2}\"",
       Driver, llvm::join(Info->SystemIncludes, ", "), Info->Target);

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index 567e4fd9bca68..9bd48825cf077 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -140,7 +140,7 @@ static clang::clangd::Key<std::string> FileBeingProcessed;
 llvm::Optional<llvm::StringRef> TUScheduler::getFileBeingProcessedInContext() {
   if (auto *File = Context::current().get(FileBeingProcessed))
     return llvm::StringRef(*File);
-  return None;
+  return std::nullopt;
 }
 
 /// An LRU cache of idle ASTs.
@@ -192,7 +192,7 @@ class TUScheduler::ASTCache {
     if (Existing == LRU.end()) {
       if (AccessMetric)
         AccessMetric->record(1, "miss");
-      return None;
+      return std::nullopt;
     }
     if (AccessMetric)
       AccessMetric->record(1, "hit");
@@ -996,7 +996,7 @@ void ASTWorker::runWithAST(
          FileInputs.Version);
     Action(InputsAndAST{FileInputs, **AST});
   };
-  startTask(Name, std::move(Task), /*Update=*/None, Invalidation);
+  startTask(Name, std::move(Task), /*Update=*/std::nullopt, Invalidation);
 }
 
 /// To be called from ThreadCrashReporter's signal handler.
@@ -1132,7 +1132,7 @@ void ASTWorker::updatePreamble(std::unique_ptr<CompilerInvocation> CI,
     std::lock_guard<std::mutex> Lock(Mutex);
     PreambleRequests.push_back({std::move(Task), std::string(TaskName),
                                 steady_clock::now(), Context::current().clone(),
-                                llvm::None, llvm::None,
+                                std::nullopt, std::nullopt,
                                 TUScheduler::NoInvalidation, nullptr});
   }
   PreambleCV.notify_all();
@@ -1464,12 +1464,12 @@ Deadline ASTWorker::scheduleLocked() {
   for (auto I = Requests.begin(), E = Requests.end(); I != E; ++I) {
     if (!isCancelled(I->Ctx)) {
       // Cancellations after the first read don't affect current scheduling.
-      if (I->Update == None)
+      if (I->Update == std::nullopt)
         break;
       continue;
     }
     // Cancelled reads are moved to the front of the queue and run immediately.
-    if (I->Update == None) {
+    if (I->Update == std::nullopt) {
       Request R = std::move(*I);
       Requests.erase(I);
       Requests.push_front(std::move(R));
@@ -1490,7 +1490,8 @@ Deadline ASTWorker::scheduleLocked() {
   // We debounce "maybe-unused" writes, sleeping in case they become dead.
   // But don't delay reads (including updates where diagnostics are needed).
   for (const auto &R : Requests)
-    if (R.Update == None || R.Update->Diagnostics == WantDiagnostics::Yes)
+    if (R.Update == std::nullopt ||
+        R.Update->Diagnostics == WantDiagnostics::Yes)
       return Deadline::zero();
   // Front request needs to be debounced, so determine when we're ready.
   Deadline D(Requests.front().AddTime + UpdateDebounce.compute(RebuildTimes));

diff  --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index 10fb14b2ba8c6..644d7fe7cfaf0 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -119,16 +119,16 @@ void logIfOverflow(const SymbolLocation &Loc) {
 llvm::Optional<Location> toLSPLocation(const SymbolLocation &Loc,
                                        llvm::StringRef TUPath) {
   if (!Loc)
-    return None;
+    return std::nullopt;
   auto Uri = URI::parse(Loc.FileURI);
   if (!Uri) {
     elog("Could not parse URI {0}: {1}", Loc.FileURI, Uri.takeError());
-    return None;
+    return std::nullopt;
   }
   auto U = URIForFile::fromURI(*Uri, TUPath);
   if (!U) {
     elog("Could not resolve URI {0}: {1}", Loc.FileURI, U.takeError());
-    return None;
+    return std::nullopt;
   }
 
   Location LSPLoc;
@@ -210,11 +210,11 @@ llvm::Optional<Location> makeLocation(const ASTContext &AST, SourceLocation Loc,
   const auto &SM = AST.getSourceManager();
   const FileEntry *F = SM.getFileEntryForID(SM.getFileID(Loc));
   if (!F)
-    return None;
+    return std::nullopt;
   auto FilePath = getCanonicalPath(F, SM);
   if (!FilePath) {
     log("failed to get path!");
-    return None;
+    return std::nullopt;
   }
   Location L;
   L.uri = URIForFile::canonicalize(*FilePath, TUPath);
@@ -241,7 +241,7 @@ llvm::Optional<LocatedSymbol> locateFileReferent(const Position &Pos,
       return File;
     }
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Macros are simple: there's no declaration/definition distinction.
@@ -260,7 +260,7 @@ locateMacroReferent(const syntax::Token &TouchedIdentifier, ParsedAST &AST,
       return Macro;
     }
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 // A wrapper around `Decl::getCanonicalDecl` to support cases where Clang's
@@ -1209,7 +1209,7 @@ llvm::Optional<DocumentHighlight> toHighlight(SourceLocation Loc,
         CharSourceRange::getCharRange(Tok->location(), Tok->endLocation()));
     return Result;
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 } // namespace
@@ -1569,11 +1569,11 @@ declToHierarchyItem(const NamedDecl &ND, llvm::StringRef TUPath) {
   const auto DeclRange =
       toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
   if (!DeclRange)
-    return llvm::None;
+    return std::nullopt;
   auto FilePath =
       getCanonicalPath(SM.getFileEntryForID(SM.getFileID(NameLoc)), SM);
   if (!FilePath)
-    return llvm::None; // Not useful without a uri.
+    return std::nullopt; // Not useful without a uri.
 
   Position NameBegin = sourceLocToPosition(SM, NameLoc);
   Position NameEnd = sourceLocToPosition(
@@ -1633,7 +1633,7 @@ static llvm::Optional<HierarchyItem> symbolToHierarchyItem(const Symbol &S,
   auto Loc = symbolToLocation(S, TUPath);
   if (!Loc) {
     elog("Failed to convert symbol to hierarchy item: {0}", Loc.takeError());
-    return llvm::None;
+    return std::nullopt;
   }
   HierarchyItem HI;
   HI.name = std::string(S.Name);
@@ -2065,7 +2065,7 @@ llvm::Optional<std::vector<TypeHierarchyItem>>
 superTypes(const TypeHierarchyItem &Item, const SymbolIndex *Index) {
   std::vector<TypeHierarchyItem> Results;
   if (!Item.data.parents)
-    return llvm::None;
+    return std::nullopt;
   if (Item.data.parents->empty())
     return Results;
   LookupRequest Req;

diff  --git a/clang-tools-extra/clangd/index/Background.cpp b/clang-tools-extra/clangd/index/Background.cpp
index b5349468eb24f..2b75b8b585020 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -396,7 +396,7 @@ BackgroundIndex::loadProject(std::vector<std::string> MainFiles) {
   Rebuilder.loadedShard(LoadedShards);
   Rebuilder.doneLoading();
 
-  auto FS = TFS.view(/*CWD=*/llvm::None);
+  auto FS = TFS.view(/*CWD=*/std::nullopt);
   llvm::DenseSet<PathRef> TUsToIndex;
   // We'll accept data from stale shards, but ensure the files get reindexed
   // soon.

diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp
index dcfc4b5981fa2..1080cb0f4b81e 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -192,7 +192,7 @@ llvm::Optional<IndexFileIn>
 FileShardedIndex::getShard(llvm::StringRef Uri) const {
   auto It = Shards.find(Uri);
   if (It == Shards.end())
-    return llvm::None;
+    return std::nullopt;
 
   IndexFileIn IF;
   IF.Sources = It->getValue().IG;

diff  --git a/clang-tools-extra/clangd/index/IndexAction.cpp b/clang-tools-extra/clangd/index/IndexAction.cpp
index 431fce85b4d8f..aaba2c90056da 100644
--- a/clang-tools-extra/clangd/index/IndexAction.cpp
+++ b/clang-tools-extra/clangd/index/IndexAction.cpp
@@ -30,10 +30,10 @@ namespace {
 
 llvm::Optional<std::string> toURI(Optional<FileEntryRef> File) {
   if (!File)
-    return llvm::None;
+    return std::nullopt;
   auto AbsolutePath = File->getFileEntry().tryGetRealPathName();
   if (AbsolutePath.empty())
-    return llvm::None;
+    return std::nullopt;
   return URI::create(AbsolutePath).toString();
 }
 

diff  --git a/clang-tools-extra/clangd/index/StdLib.cpp b/clang-tools-extra/clangd/index/StdLib.cpp
index f2edc514bae30..3ade3e1d7abad 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -228,7 +228,7 @@ SymbolSlab indexStandardLibrary(llvm::StringRef HeaderSources,
   auto Clang = prepareCompilerInstance(
       std::move(CI), /*Preamble=*/nullptr,
       llvm::MemoryBuffer::getMemBuffer(HeaderSources, Input.getFile()),
-      TFS.view(/*CWD=*/llvm::None), IgnoreDiags);
+      TFS.view(/*CWD=*/std::nullopt), IgnoreDiags);
   if (!Clang) {
     elog("Standard Library Index: Couldn't build compiler instance");
     return Symbols;
@@ -296,7 +296,7 @@ llvm::Optional<StdLibLocation> StdLibSet::add(const LangOptions &LO,
 
   if (!Config::current().Index.StandardLibrary) {
     dlog("No: disabled in config");
-    return llvm::None;
+    return std::nullopt;
   }
 
   if (NewVersion <= OldVersion) {
@@ -305,7 +305,7 @@ llvm::Optional<StdLibLocation> StdLibSet::add(const LangOptions &LO,
              static_cast<LangStandard::Kind>(NewVersion))
              .getName(),
          OldVersion, NewVersion);
-    return llvm::None;
+    return std::nullopt;
   }
 
   // We'd like to index a standard library here if there is one.
@@ -344,7 +344,7 @@ llvm::Optional<StdLibLocation> StdLibSet::add(const LangOptions &LO,
     }
   }
   if (SearchPaths.empty())
-    return llvm::None;
+    return std::nullopt;
 
   dlog("Found standard library in {0}", llvm::join(SearchPaths, ", "));
 
@@ -352,7 +352,8 @@ llvm::Optional<StdLibLocation> StdLibSet::add(const LangOptions &LO,
                                         std::memory_order_acq_rel))
     if (OldVersion >= NewVersion) {
       dlog("No: lost the race");
-      return llvm::None; // Another thread won the race while we were checking.
+      return std::nullopt; // Another thread won the race while we were
+                           // checking.
     }
 
   dlog("Yes, index stdlib!");

diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index a943746fab5de..54dfde4342175 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -148,7 +148,7 @@ llvm::Optional<RelationKind> indexableRelation(const index::SymbolRelation &R) {
     return RelationKind::BaseOf;
   if (R.Roles & static_cast<unsigned>(index::SymbolRole::RelationOverrideOf))
     return RelationKind::OverriddenBy;
-  return None;
+  return std::nullopt;
 }
 
 // Given a ref contained in enclosing decl `Enclosing`, return
@@ -310,7 +310,7 @@ class SymbolCollector::HeaderFileURICache {
       ++I;
     }
     // Unexpected, must not be a framework header.
-    return llvm::None;
+    return std::nullopt;
   }
 
   // Frameworks typically have an umbrella header of the same name, e.g.
@@ -374,7 +374,7 @@ class SymbolCollector::HeaderFileURICache {
       // Unexpected: must not be a proper framework header, don't cache the
       // failure.
       CachePathToFrameworkSpelling.erase(Res.first);
-      return llvm::None;
+      return std::nullopt;
     }
     auto DirKind = HS.getFileDirFlavor(FE);
     if (auto UmbrellaSpelling =
@@ -441,7 +441,7 @@ SymbolCollector::getTokenLocation(SourceLocation TokLoc) {
   const auto &SM = ASTCtx->getSourceManager();
   auto *FE = SM.getFileEntryForID(SM.getFileID(TokLoc));
   if (!FE)
-    return None;
+    return std::nullopt;
 
   SymbolLocation Result;
   Result.FileURI = HeaderFileURIs->toURI(FE).c_str();

diff  --git a/clang-tools-extra/clangd/index/dex/PostingList.cpp b/clang-tools-extra/clangd/index/dex/PostingList.cpp
index 2a61297682e49..c1bd338de69d9 100644
--- a/clang-tools-extra/clangd/index/dex/PostingList.cpp
+++ b/clang-tools-extra/clangd/index/dex/PostingList.cpp
@@ -184,7 +184,7 @@ std::vector<Chunk> encodeStream(llvm::ArrayRef<DocID> Documents) {
 /// the stream is terminated, return None.
 llvm::Optional<DocID> readVByte(llvm::ArrayRef<uint8_t> &Bytes) {
   if (Bytes.front() == 0 || Bytes.empty())
-    return llvm::None;
+    return std::nullopt;
   DocID Result = 0;
   bool HasNextByte = true;
   for (size_t Length = 0; HasNextByte && !Bytes.empty(); ++Length) {

diff  --git a/clang-tools-extra/clangd/refactor/InsertionPoint.cpp b/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
index ce5f3a5a1d5fd..3158863cbb3c9 100644
--- a/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
+++ b/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
@@ -59,7 +59,7 @@ llvm::Optional<const Decl *> insertionDecl(const DeclContext &DC,
   }
   if (ReturnNext || (LastMatched && A.Direction == Anchor::Below))
     return nullptr;
-  return llvm::None;
+  return std::nullopt;
 }
 
 SourceLocation beginLoc(const Decl &D) {

diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp
index daddd02876b38..eb6a22e1381db 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -42,11 +42,11 @@ namespace {
 llvm::Optional<std::string> filePath(const SymbolLocation &Loc,
                                      llvm::StringRef HintFilePath) {
   if (!Loc)
-    return None;
+    return std::nullopt;
   auto Path = URI::resolve(Loc.FileURI, HintFilePath);
   if (!Path) {
     elog("Could not resolve URI {0}: {1}", Loc.FileURI, Path.takeError());
-    return None;
+    return std::nullopt;
   }
 
   return *Path;
@@ -217,7 +217,7 @@ llvm::Optional<ReasonToReject> renameable(const NamedDecl &RenameDecl,
   }
   // function-local symbols is safe to rename.
   if (RenameDecl.getParentFunctionOrMethod())
-    return None;
+    return std::nullopt;
 
   if (isExcluded(RenameDecl))
     return ReasonToReject::UnsupportedSymbol;
@@ -239,7 +239,7 @@ llvm::Optional<ReasonToReject> renameable(const NamedDecl &RenameDecl,
           IsMainFileOnly))
     return ReasonToReject::NonIndexable;
 
-  return None;
+  return std::nullopt;
 }
 
 llvm::Error makeError(ReasonToReject Reason) {
@@ -935,7 +935,7 @@ llvm::Optional<std::vector<Range>> getMappedRanges(ArrayRef<Range> Indexed,
     SPAN_ATTACH(
         Tracer, "error",
         "The number of lexed occurrences is less than indexed occurrences");
-    return llvm::None;
+    return std::nullopt;
   }
   // Fast check for the special subset case.
   if (std::includes(Indexed.begin(), Indexed.end(), Lexed.begin(), Lexed.end()))
@@ -962,12 +962,12 @@ llvm::Optional<std::vector<Range>> getMappedRanges(ArrayRef<Range> Indexed,
   if (HasMultiple) {
     vlog("The best near miss is not unique.");
     SPAN_ATTACH(Tracer, "error", "The best near miss is not unique");
-    return llvm::None;
+    return std::nullopt;
   }
   if (Best.empty()) {
     vlog("Didn't find a near miss.");
     SPAN_ATTACH(Tracer, "error", "Didn't find a near miss");
-    return llvm::None;
+    return std::nullopt;
   }
   std::vector<Range> Mapped;
   for (auto I : Best)

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index 96d0a194fb892..418f592cc70aa 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -60,7 +60,7 @@ llvm::Optional<SourceLocation> getSemicolonForDecl(const FunctionDecl *FD) {
   SourceLocation CurLoc = FD->getEndLoc();
   auto NextTok = Lexer::findNextToken(CurLoc, SM, LangOpts);
   if (!NextTok || !NextTok->is(tok::semi))
-    return llvm::None;
+    return std::nullopt;
   return NextTok->getLocation();
 }
 
@@ -353,17 +353,17 @@ llvm::Optional<tooling::Replacement>
 addInlineIfInHeader(const FunctionDecl *FD) {
   // This includes inline functions and constexpr functions.
   if (FD->isInlined() || llvm::isa<CXXMethodDecl>(FD))
-    return llvm::None;
+    return std::nullopt;
   // Primary template doesn't need inline.
   if (FD->isTemplated() && !FD->isFunctionTemplateSpecialization())
-    return llvm::None;
+    return std::nullopt;
 
   const SourceManager &SM = FD->getASTContext().getSourceManager();
   llvm::StringRef FileName = SM.getFilename(FD->getLocation());
 
   // If it is not a header we don't need to mark function as "inline".
   if (!isHeaderFile(FileName, FD->getASTContext().getLangOpts()))
-    return llvm::None;
+    return std::nullopt;
 
   return tooling::Replacement(SM, FD->getInnerLocStart(), 0, "inline ");
 }

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 2666ab2a8a93b..93c1e3f007b59 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -93,7 +93,7 @@ findContextForNS(llvm::StringRef TargetNS, const DeclContext *CurContext) {
   // If TargetNS is not a prefix of CurrentContext, there's no way to reach
   // it.
   if (!CurrentContextNS.startswith(TargetNS))
-    return llvm::None;
+    return std::nullopt;
 
   while (CurrentContextNS != TargetNS) {
     CurContext = CurContext->getParent();

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
index 28489dcc75a73..62bdf534dadd7 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -118,7 +118,7 @@ Expected<Tweak::Effect> ExpandAutoType::apply(const Selection& Inputs) {
       getDeducedType(Inputs.AST->getASTContext(), AutoRange.getBegin());
 
   // if we can't resolve the type, return an error message
-  if (DeducedType == llvm::None || (*DeducedType)->isUndeducedAutoType())
+  if (DeducedType == std::nullopt || (*DeducedType)->isUndeducedAutoType())
     return error("Could not deduce type for 'auto' type");
 
   // if it's a lambda expression, return an error message

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 3b2e7d2bb86a7..4d33708bf9e64 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -273,12 +273,12 @@ llvm::Optional<SourceRange> findZoneRange(const Node *Parent,
           SM, LangOpts, Parent->Children.front()->ASTNode.getSourceRange()))
     SR.setBegin(BeginFileRange->getBegin());
   else
-    return llvm::None;
+    return std::nullopt;
   if (auto EndFileRange = toHalfOpenFileRange(
           SM, LangOpts, Parent->Children.back()->ASTNode.getSourceRange()))
     SR.setEnd(EndFileRange->getEnd());
   else
-    return llvm::None;
+    return std::nullopt;
   return SR;
 }
 
@@ -317,22 +317,22 @@ llvm::Optional<ExtractionZone> findExtractionZone(const Node *CommonAnc,
   ExtractionZone ExtZone;
   ExtZone.Parent = getParentOfRootStmts(CommonAnc);
   if (!ExtZone.Parent || ExtZone.Parent->Children.empty())
-    return llvm::None;
+    return std::nullopt;
   ExtZone.EnclosingFunction = findEnclosingFunction(ExtZone.Parent);
   if (!ExtZone.EnclosingFunction)
-    return llvm::None;
+    return std::nullopt;
   // When there is a single RootStmt, we must check if it's valid for
   // extraction.
   if (ExtZone.Parent->Children.size() == 1 &&
       !validSingleChild(ExtZone.getLastRootStmt(), ExtZone.EnclosingFunction))
-    return llvm::None;
+    return std::nullopt;
   if (auto FuncRange =
           computeEnclosingFuncRange(ExtZone.EnclosingFunction, SM, LangOpts))
     ExtZone.EnclosingFuncRange = *FuncRange;
   if (auto ZoneRange = findZoneRange(ExtZone.Parent, SM, LangOpts))
     ExtZone.ZoneRange = *ZoneRange;
   if (ExtZone.EnclosingFuncRange.isInvalid() || ExtZone.ZoneRange.isInvalid())
-    return llvm::None;
+    return std::nullopt;
 
   for (const Node *Child : ExtZone.Parent->Children)
     ExtZone.RootStmts.insert(Child->ASTNode.get<Stmt>());

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
index 502a76e60fc9a..c000e74307647 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
@@ -96,7 +96,7 @@ struct MethodParameter {
     if (const auto *PD = dyn_cast<ObjCPropertyDecl>(&D))
       if (PD->isInstanceProperty())
         return MethodParameter(*PD);
-    return llvm::None;
+    return std::nullopt;
   }
 };
 

diff  --git a/clang-tools-extra/clangd/support/FileCache.cpp b/clang-tools-extra/clangd/support/FileCache.cpp
index ad5f7ea876712..36804113a9bbe 100644
--- a/clang-tools-extra/clangd/support/FileCache.cpp
+++ b/clang-tools-extra/clangd/support/FileCache.cpp
@@ -47,11 +47,11 @@ void FileCache::read(
 
   // stat is cheaper than opening the file. It's usually unchanged.
   assert(llvm::sys::path::is_absolute(Path));
-  auto FS = TFS.view(/*CWD=*/llvm::None);
+  auto FS = TFS.view(/*CWD=*/std::nullopt);
   auto Stat = FS->status(Path);
   if (!Stat || !Stat->isRegularFile()) {
     if (Size != FileNotFound) // Allow "not found" value to be cached.
-      Parse(llvm::None);
+      Parse(std::nullopt);
     // Ensure the cache key won't match any future stat().
     Size = FileNotFound;
     return;

diff  --git a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
index dca04762b49a6..f72e45f2b92f9 100644
--- a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
+++ b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
@@ -74,7 +74,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 
 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
 ThreadsafeFS::view(PathRef CWD) const {
-  auto FS = view(llvm::None);
+  auto FS = view(std::nullopt);
   if (auto EC = FS->setCurrentWorkingDirectory(CWD))
     elog("VFS: failed to set CWD to {0}: {1}", CWD, EC.message());
   return FS;

diff  --git a/clang-tools-extra/clangd/tool/Check.cpp b/clang-tools-extra/clangd/tool/Check.cpp
index 02bf1d8515b3c..ccd2ac2baa582 100644
--- a/clang-tools-extra/clangd/tool/Check.cpp
+++ b/clang-tools-extra/clangd/tool/Check.cpp
@@ -178,7 +178,7 @@ class Checker {
       Inputs.Contents = *Contents;
       log("Imaginary source file contents:\n{0}", Inputs.Contents);
     } else {
-      if (auto Contents = TFS.view(llvm::None)->getBufferForFile(File)) {
+      if (auto Contents = TFS.view(std::nullopt)->getBufferForFile(File)) {
         Inputs.Contents = Contents->get()->getBuffer().str();
       } else {
         elog("Couldn't read {0}: {1}", File, Contents.getError().message());

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 fc21eff357924..ac911be45de96 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -222,7 +222,7 @@ class LRTable {
       Word KeyMask = Word(1) << (Key % WordBits);
       unsigned KeyWord = Key / WordBits;
       if ((HasValue[KeyWord] & KeyMask) == 0)
-        return llvm::None;
+        return std::nullopt;
       // Count the number of values since the checkpoint.
       Word BelowKeyMask = KeyMask - 1;
       unsigned CountSinceCheckpoint =

diff  --git a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
index c9e0198227fa4..2d0199c630998 100644
--- a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
+++ b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp
@@ -92,7 +92,7 @@ class DirectiveParser {
         Tree->Chunks.push_back(std::move(Directive));
       }
     }
-    return None;
+    return std::nullopt;
   }
 
   // Parse the rest of a conditional section, after seeing the If directive.
@@ -292,7 +292,7 @@ class BranchChooser {
     case clang::tok::pp_else:
       return true;
     default: // #ifdef etc
-      return llvm::None;
+      return std::nullopt;
     }
 
     const auto &Tokens = Code.tokens(Dir.Tokens);
@@ -301,11 +301,11 @@ class BranchChooser {
     const Token &Value = Name.nextNC();
     // Does the condition consist of exactly one token?
     if (&Value >= Tokens.end() || &Value.nextNC() < Tokens.end())
-      return llvm::None;
+      return std::nullopt;
     return llvm::StringSwitch<llvm::Optional<bool>>(Value.text())
         .Cases("true", "1", true)
         .Cases("false", "0", false)
-        .Default(llvm::None);
+        .Default(std::nullopt);
   }
 
   const TokenStream &Code;

diff  --git a/clang-tools-extra/pseudo/lib/Forest.cpp b/clang-tools-extra/pseudo/lib/Forest.cpp
index 131dd4dca8393..d24a90fd1fe0e 100644
--- a/clang-tools-extra/pseudo/lib/Forest.cpp
+++ b/clang-tools-extra/pseudo/lib/Forest.cpp
@@ -167,12 +167,12 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
             LineDec.Subsequent = "│ ";
           }
           Dump(Children[I], P->kind() == Sequence ? EndOfElement(I) : End,
-               llvm::None, LineDec);
+               std::nullopt, LineDec);
         }
         LineDec.Prefix.resize(OldPrefixSize);
       };
   LineDecoration LineDec;
-  Dump(this, KEnd, llvm::None, LineDec);
+  Dump(this, KEnd, std::nullopt, LineDec);
   return Result;
 }
 

diff  --git a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
index 19fefac206b73..8c1338cff0379 100644
--- a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -51,7 +51,7 @@ llvm::Optional<SymbolID> Grammar::findNonterminal(llvm::StringRef Name) const {
       [&](const GrammarTable::Nonterminal &X) { return X.Name < Name; });
   if (It != T->Nonterminals.end() && It->Name == Name)
     return It - T->Nonterminals.begin();
-  return llvm::None;
+  return std::nullopt;
 }
 
 std::string Grammar::dumpRule(RuleID RID) const {


        


More information about the cfe-commits mailing list