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

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


Author: Kazu Hirata
Date: 2022-12-03T11:54:48-08:00
New Revision: cd8702efe7e6cacfd82cc4909e42718224bcd5d0

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

LOG: [clang-tidy] 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-tidy/ClangTidyCheck.cpp
    clang-tools-extra/clang-tidy/ClangTidyCheck.h
    clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
    clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
    clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
    clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
    clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
    clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
    clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
    clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
    clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
    clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
    clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
    clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
    clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
    clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
    clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
    clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
    clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
    clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
    clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
    clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
    clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
    clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
    clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
    clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
    clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
    clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
    clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
    clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
    clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
    clang-tools-extra/clang-tidy/utils/UsingInserter.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 83aef0a40c9a1..6bb0b2ac32513 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -58,7 +58,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
   const auto &Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter != CheckOptions.end())
     return StringRef(Iter->getValue().Value);
-  return None;
+  return std::nullopt;
 }
 
 static ClangTidyOptions::OptionMap::const_iterator
@@ -86,7 +86,7 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
                                  Context->getOptionsCollector());
   if (Iter != CheckOptions.end())
     return StringRef(Iter->getValue().Value);
-  return None;
+  return std::nullopt;
 }
 
 static Optional<bool> getAsBool(StringRef Value,
@@ -99,7 +99,7 @@ static Optional<bool> getAsBool(StringRef Value,
   long long Number;
   if (!Value.getAsInteger(10, Number))
     return Number != 0;
-  return None;
+  return std::nullopt;
 }
 
 template <>
@@ -110,7 +110,7 @@ ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const {
       return Result;
     diagnoseBadBooleanOption(NamePrefix + LocalName, *ValueOr);
   }
-  return None;
+  return std::nullopt;
 }
 
 template <>
@@ -123,7 +123,7 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
       return Result;
     diagnoseBadBooleanOption(Iter->getKey(), Iter->getValue().Value);
   }
-  return None;
+  return std::nullopt;
 }
 
 void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
@@ -155,7 +155,7 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
                                        Context->getOptionsCollector())
                   : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
-    return None;
+    return std::nullopt;
 
   StringRef Value = Iter->getValue().Value;
   StringRef Closest;
@@ -182,7 +182,7 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
     diagnoseBadEnumOption(Iter->getKey(), Iter->getValue().Value, Closest);
   else
     diagnoseBadEnumOption(Iter->getKey(), Iter->getValue().Value);
-  return None;
+  return std::nullopt;
 }
 
 static constexpr llvm::StringLiteral ConfigWarning(

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index abf528d655972..cb5933652a480 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -198,7 +198,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
           return Result;
         diagnoseBadIntegerOption(NamePrefix + LocalName, *Value);
       }
-      return None;
+      return std::nullopt;
     }
 
     /// Read a named option from the ``Context`` and parse it as an
@@ -235,14 +235,14 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
         IsGlobal = true;
         ValueOr = getLocalOrGlobal(LocalName);
         if (!ValueOr)
-          return None;
+          return std::nullopt;
       }
       T Result{};
       if (!StringRef(*ValueOr).getAsInteger(10, Result))
         return Result;
       diagnoseBadIntegerOption(
           IsGlobal ? Twine(LocalName) : NamePrefix + LocalName, *ValueOr);
-      return None;
+      return std::nullopt;
     }
 
     /// Read a named option from the ``Context`` and parse it as an
@@ -279,7 +279,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
       if (llvm::Optional<int64_t> ValueOr =
               getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
         return static_cast<T>(*ValueOr);
-      return None;
+      return std::nullopt;
     }
 
     /// Read a named option from the ``Context`` and parse it as an
@@ -319,7 +319,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
       if (llvm::Optional<int64_t> ValueOr =
               getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
         return static_cast<T>(*ValueOr);
-      return None;
+      return std::nullopt;
     }
 
     /// Read a named option from the ``Context`` and parse it as an

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 1660d976ff0be..e6b907038a7e1 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -258,7 +258,7 @@ void ClangTidyContext::setProfileStoragePrefix(StringRef Prefix) {
 llvm::Optional<ClangTidyProfiling::StorageParams>
 ClangTidyContext::getProfileStorageParams() const {
   if (ProfilePrefix.empty())
-    return llvm::None;
+    return std::nullopt;
 
   return ClangTidyProfiling::StorageParams(ProfilePrefix, CurrentFile);
 }

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index f07a8f9e893d8..c98ecb8bb29ad 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -147,7 +147,7 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
-  Options.User = llvm::None;
+  Options.User = std::nullopt;
   for (const ClangTidyModuleRegistry::entry &Module :
        ClangTidyModuleRegistry::entries())
     Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
@@ -368,7 +368,7 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef Directory) {
   if (!DirectoryStatus || !DirectoryStatus->isDirectory()) {
     llvm::errs() << "Error reading configuration from " << Directory
                  << ": directory doesn't exist.\n";
-    return llvm::None;
+    return std::nullopt;
   }
 
   for (const ConfigFileHandler &ConfigHandler : ConfigHandlers) {
@@ -403,7 +403,7 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef Directory) {
     }
     return OptionsSource(*ParsedOptions, std::string(ConfigFile));
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 /// Parses -line-filter option and stores it to the \c Options.

diff  --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
index eb787154e4e4a..076e8fd2f625f 100644
--- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
+++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
@@ -52,7 +52,7 @@ static Optional<NoLintType> strToNoLintType(StringRef Str) {
                   .Case("NOLINTNEXTLINE", NoLintType::NoLintNextLine)
                   .Case("NOLINTBEGIN", NoLintType::NoLintBegin)
                   .Case("NOLINTEND", NoLintType::NoLintEnd)
-                  .Default(None);
+                  .Default(std::nullopt);
   return Type;
 }
 

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index dbc3cf2e6128f..17ec54e587b4e 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -30,7 +30,7 @@ getScaleForFactory(llvm::StringRef FactoryName) {
       .Case("Seconds", DurationScale::Seconds)
       .Case("Minutes", DurationScale::Minutes)
       .Case("Hours", DurationScale::Hours)
-      .Default(llvm::None);
+      .Default(std::nullopt);
 }
 
 // Given either an integer or float literal, return its value.
@@ -89,7 +89,7 @@ getNewScaleSingleStep(DurationScale OldScale, double Multiplier) {
     break;
   }
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 // Given the scale of a duration and a `Multiplier`, determine if `Multiplier`
@@ -107,7 +107,7 @@ static llvm::Optional<DurationScale> getNewScale(DurationScale OldScale,
     OldScale = std::get<0>(*Result);
   }
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 void DurationFactoryScaleCheck::registerMatchers(MatchFinder *Finder) {

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index 68e8bcf50c365..48000482ce240 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -31,11 +31,11 @@ truncateIfIntegral(const FloatingLiteral &FloatLiteral) {
   double Value = FloatLiteral.getValueAsApproximateDouble();
   if (std::fmod(Value, 1) == 0) {
     if (Value >= static_cast<double>(1u << 31))
-      return llvm::None;
+      return std::nullopt;
 
     return llvm::APSInt::get(static_cast<int64_t>(Value));
   }
-  return llvm::None;
+  return std::nullopt;
 }
 
 const std::pair<llvm::StringRef, llvm::StringRef> &
@@ -83,7 +83,7 @@ rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
     return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
   }
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 /// If `Node` is a call to the inverse of `Scale`, return that inverse's
@@ -99,7 +99,7 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
     return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
   }
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 /// Returns the factory function name for a given `Scale`.
@@ -201,7 +201,7 @@ stripFloatCast(const ast_matchers::MatchFinder::MatchResult &Result,
                 Node, *Result.Context)))
     return tooling::fixit::getText(*MaybeCastArg, *Result.Context).str();
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 llvm::Optional<std::string>
@@ -212,7 +212,7 @@ stripFloatLiteralFraction(const MatchFinder::MatchResult &Result,
     if (llvm::Optional<llvm::APSInt> IntValue = truncateIfIntegral(*LitFloat))
       return toString(*IntValue, /*radix=*/10);
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 std::string simplifyDurationFactoryArg(const MatchFinder::MatchResult &Result,
@@ -247,7 +247,7 @@ llvm::Optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
 
   auto ScaleIter = ScaleMap.find(std::string(Name));
   if (ScaleIter == ScaleMap.end())
-    return llvm::None;
+    return std::nullopt;
 
   return ScaleIter->second;
 }
@@ -263,7 +263,7 @@ llvm::Optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
 
   auto ScaleIter = ScaleMap.find(std::string(Name));
   if (ScaleIter == ScaleMap.end())
-    return llvm::None;
+    return std::nullopt;
 
   return ScaleIter->second;
 }

diff  --git a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
index efb3faa7cff87..b73b1002763c5 100644
--- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -45,11 +45,11 @@ llvm::Optional<std::string> makeCharacterLiteral(const StringLiteral *Literal,
   // Now replace the " with '.
   std::string::size_type Pos = Result.find_first_of('"');
   if (Pos == Result.npos)
-    return llvm::None;
+    return std::nullopt;
   Result[Pos] = '\'';
   Pos = Result.find_last_of('"');
   if (Pos == Result.npos)
-    return llvm::None;
+    return std::nullopt;
   Result[Pos] = '\'';
   return Result;
 }

diff  --git a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
index cef7fd5935ffa..f1bfcc84c95f5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
@@ -36,17 +36,17 @@ void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) {
   const auto TryExpandAsInteger =
       [](Preprocessor::macro_iterator It) -> Optional<unsigned> {
     if (It == PP->macro_end())
-      return llvm::None;
+      return std::nullopt;
     const MacroInfo *MI = PP->getMacroInfo(It->first);
     const Token &T = MI->tokens().back();
     if (!T.isLiteral() || !T.getLiteralData())
-      return llvm::None;
+      return std::nullopt;
     StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
 
     llvm::APInt IntValue;
     constexpr unsigned AutoSenseRadix = 0;
     if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
-      return llvm::None;
+      return std::nullopt;
     return IntValue.getZExtValue();
   };
 

diff  --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 0f6a97eb84851..ea3d64ef700e8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -753,7 +753,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   auto MemcpyS = Match({"memcpy_s", 0, 2, 3, false});
 
   // void *memchr(const void *src, int c, size_t count)
-  auto Memchr = Match({"memchr", None, 0, 2, false});
+  auto Memchr = Match({"memchr", std::nullopt, 0, 2, false});
 
   // void *memmove(void *dest, const void *src, size_t count)
   auto Memmove = Match({"memmove", 0, 1, 2, false});
@@ -762,14 +762,14 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   auto MemmoveS = Match({"memmove_s", 0, 2, 3, false});
 
   // int strncmp(const char *str1, const char *str2, size_t count);
-  auto StrncmpRHS = Match({"strncmp", None, 1, 2, true});
-  auto StrncmpLHS = Match({"strncmp", None, 0, 2, true});
+  auto StrncmpRHS = Match({"strncmp", std::nullopt, 1, 2, true});
+  auto StrncmpLHS = Match({"strncmp", std::nullopt, 0, 2, true});
 
   // size_t strxfrm(char *dest, const char *src, size_t count);
   auto Strxfrm = Match({"strxfrm", 0, 1, 2, false});
 
   // errno_t strerror_s(char *buffer, size_t bufferSize, int errnum);
-  auto StrerrorS = Match({"strerror_s", 0, None, 1, false});
+  auto StrerrorS = Match({"strerror_s", 0, std::nullopt, 1, false});
 
   auto AnyOfMatchers = anyOf(Memcpy, MemcpyS, Memmove, MemmoveS, StrncmpRHS,
                              StrncmpLHS, Strxfrm, StrerrorS);

diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 75326e0ab1d19..90c1f7ecdc0ec 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -72,7 +72,7 @@ static Optional<std::string>
 getDoubleUnderscoreFixup(StringRef Name, const LangOptions &LangOpts) {
   if (hasReservedDoubleUnderscore(Name, LangOpts))
     return collapseConsecutive(Name, '_');
-  return None;
+  return std::nullopt;
 }
 
 static bool startsWithUnderscoreCapital(StringRef Name) {
@@ -82,7 +82,7 @@ static bool startsWithUnderscoreCapital(StringRef Name) {
 static Optional<std::string> getUnderscoreCapitalFixup(StringRef Name) {
   if (startsWithUnderscoreCapital(Name))
     return std::string(Name.drop_front(1));
-  return None;
+  return std::nullopt;
 }
 
 static bool startsWithUnderscoreInGlobalNamespace(StringRef Name,
@@ -94,7 +94,7 @@ static Optional<std::string>
 getUnderscoreGlobalNamespaceFixup(StringRef Name, bool IsInGlobalNamespace) {
   if (startsWithUnderscoreInGlobalNamespace(Name, IsInGlobalNamespace))
     return std::string(Name.drop_front(1));
-  return None;
+  return std::nullopt;
 }
 
 static std::string getNonReservedFixup(std::string Name) {
@@ -112,7 +112,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
                    ArrayRef<StringRef> AllowedIdentifiers) {
   assert(!Name.empty());
   if (llvm::is_contained(AllowedIdentifiers, Name))
-    return None;
+    return std::nullopt;
 
   // TODO: Check for names identical to language keywords, and other names
   // specifically reserved by language standards, e.g. C++ 'zombie names' and C
@@ -149,7 +149,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
         startsWithUnderscoreCapital(Name) ||
         startsWithUnderscoreInGlobalNamespace(Name, IsInGlobalNamespace)))
     return FailureInfo{NonReservedTag, getNonReservedFixup(std::string(Name))};
-  return None;
+  return std::nullopt;
 }
 
 Optional<RenamerClangTidyCheck::FailureInfo>

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
index 830abda449b29..d731d7d169620 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
@@ -22,7 +22,7 @@ static llvm::Optional<uint64_t> tryEvaluateSizeExpr(const Expr *SizeExpr,
   if (SizeExpr->EvaluateAsRValue(Result, Ctx))
     return Ctx.toBits(
         CharUnits::fromQuantity(Result.Val.getInt().getExtValue()));
-  return None;
+  return std::nullopt;
 }
 
 void SuspiciousMemoryComparisonCheck::registerMatchers(MatchFinder *Finder) {

diff  --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
index b2f6b9ed62843..7137b78640ff2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
@@ -46,7 +46,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) {
   Expected<ControlFlowContext> Context =
       ControlFlowContext::build(&FuncDecl, FuncDecl.getBody(), &ASTCtx);
   if (!Context)
-    return llvm::None;
+    return std::nullopt;
 
   dataflow::DataflowAnalysisContext AnalysisContext(
       std::make_unique<dataflow::WatchedLiteralsSolver>());
@@ -66,7 +66,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) {
             llvm::move(EltDiagnostics, std::back_inserter(Diagnostics));
           });
   if (!BlockToOutputState)
-    return llvm::None;
+    return std::nullopt;
 
   return Diagnostics;
 }

diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
index 92b38bcfd81d1..2eb6e40d98638 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -51,7 +51,7 @@ static Optional<CharSourceRange>
 getVirtualKeywordRange(const CXXDestructorDecl &Destructor,
                        const SourceManager &SM, const LangOptions &LangOpts) {
   if (Destructor.getLocation().isMacroID())
-    return None;
+    return std::nullopt;
 
   SourceLocation VirtualBeginLoc = Destructor.getBeginLoc();
   SourceLocation VirtualBeginSpellingLoc =
@@ -63,7 +63,7 @@ getVirtualKeywordRange(const CXXDestructorDecl &Destructor,
   /// virtual is included.
   Optional<Token> NextToken = Lexer::findNextToken(VirtualEndLoc, SM, LangOpts);
   if (!NextToken)
-    return None;
+    return std::nullopt;
   SourceLocation StartOfNextToken = NextToken->getLocation();
 
   return CharSourceRange::getCharRange(VirtualBeginLoc, StartOfNextToken);

diff  --git a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
index 4c6d898d4cf77..f5ab332ff46a6 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -37,7 +37,7 @@ getNewMacroName(llvm::StringRef MacroName) {
       return Mapping.second;
   }
 
-  return llvm::None;
+  return std::nullopt;
 }
 
 namespace {

diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
index d6216000fe20f..5e3e05e88f0ca 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -26,7 +26,7 @@ static llvm::Optional<const char *> getReplacementType(StringRef Type) {
       .Case("io_state", "iostate")
       .Case("open_mode", "openmode")
       .Case("seek_dir", "seekdir")
-      .Default(llvm::None);
+      .Default(std::nullopt);
 }
 
 void DeprecatedIosBaseAliasesCheck::registerMatchers(MatchFinder *Finder) {

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index a3908514d615c..9dc90937d6e54 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -212,7 +212,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
   // If the Token/Macro contains more than one type of tokens, we would need
   // to split the macro in order to move parts to the trailing return type.
   if (ContainsQualifiers + ContainsSpecifiers + ContainsSomethingElse > 1)
-    return llvm::None;
+    return std::nullopt;
 
   return CT;
 }
@@ -243,7 +243,7 @@ UseTrailingReturnTypeCheck::classifyTokensBeforeFunctionName(
         if (!MI || MI->isFunctionLike()) {
           // Cannot handle function style macros.
           diag(F.getLocation(), Message);
-          return llvm::None;
+          return std::nullopt;
         }
       }
 
@@ -255,7 +255,7 @@ UseTrailingReturnTypeCheck::classifyTokensBeforeFunctionName(
       ClassifiedTokens.push_back(*CT);
     else {
       diag(F.getLocation(), Message);
-      return llvm::None;
+      return std::nullopt;
     }
   }
 

diff  --git a/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp b/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
index 793c6021c3981..bf3463e6dedf8 100644
--- a/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
@@ -57,7 +57,7 @@ fixItHintReplacementForOwnershipString(StringRef Text, CharSourceRange Range,
                                        StringRef Ownership) {
   size_t Index = Text.find(Ownership);
   if (Index == StringRef::npos)
-    return llvm::None;
+    return std::nullopt;
 
   SourceLocation Begin = Range.getBegin().getLocWithOffset(Index);
   SourceLocation End = Begin.getLocWithOffset(Ownership.size());
@@ -71,7 +71,7 @@ fixItHintForVarDecl(const VarDecl *VD, const SourceManager &SM,
   assert(VD && "VarDecl parameter must not be null");
   // Don't provide fix-its for any parameter variables at this time.
   if (isa<ParmVarDecl>(VD))
-    return llvm::None;
+    return std::nullopt;
 
   // Currently there is no way to directly get the source range for the
   // __weak/__strong ObjC lifetime qualifiers, so it's necessary to string
@@ -81,7 +81,7 @@ fixItHintForVarDecl(const VarDecl *VD, const SourceManager &SM,
   if (Range.isInvalid()) {
     // An invalid range likely means inside a macro, in which case don't supply
     // a fix-it.
-    return llvm::None;
+    return std::nullopt;
   }
 
   StringRef VarDeclText = Lexer::getSourceText(Range, SM, LangOpts);

diff  --git a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
index 6d74aa0a9be13..e16be632d7426 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -30,11 +30,11 @@ llvm::Optional<std::string> makeCharacterLiteral(const StringLiteral *Literal) {
   // Now replace the " with '.
   auto Pos = Result.find_first_of('"');
   if (Pos == Result.npos)
-    return llvm::None;
+    return std::nullopt;
   Result[Pos] = '\'';
   Pos = Result.find_last_of('"');
   if (Pos == Result.npos)
-    return llvm::None;
+    return std::nullopt;
   Result[Pos] = '\'';
   return Result;
 }

diff  --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index f37c1ef43291c..b76f4bb6973fe 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -46,7 +46,7 @@ llvm::Optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
   bool Invalid;
   const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
   if (Invalid) {
-    return llvm::None;
+    return std::nullopt;
   }
   size_t Offset = std::strcspn(TextAfter, "\n");
   return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);

diff  --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
index 7d8bee4db96e5..412d0093b76b1 100644
--- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -28,7 +28,7 @@ static llvm::Optional<Token>
 findConstToRemove(const FunctionDecl *Def,
                   const MatchFinder::MatchResult &Result) {
   if (!Def->getReturnType().isLocalConstQualified())
-    return None;
+    return std::nullopt;
 
   // Get the begin location for the function name, including any qualifiers
   // written in the source (for out-of-line declarations). A FunctionDecl's
@@ -45,7 +45,7 @@ findConstToRemove(const FunctionDecl *Def,
       *Result.SourceManager, Result.Context->getLangOpts());
 
   if (FileRange.isInvalid())
-    return None;
+    return std::nullopt;
 
   return utils::lexer::getQualifyingToken(
       tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);

diff  --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index c0387886d9410..2cd40ed774a8a 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1361,14 +1361,14 @@ IdentifierNamingCheck::getFailureInfo(
     const IdentifierNamingCheck::HungarianNotationOption &HNOption,
     StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) const {
   if (SK == SK_Invalid || !NamingStyles[SK])
-    return None;
+    return std::nullopt;
 
   const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK];
   if (Style.IgnoredRegexp.isValid() && Style.IgnoredRegexp.match(Name))
-    return None;
+    return std::nullopt;
 
   if (matchesStyle(Type, Name, Style, HNOption, ND))
-    return None;
+    return std::nullopt;
 
   std::string KindName =
       fixupWithCase(Type, StyleNames[SK], ND, Style, HNOption,
@@ -1383,7 +1383,7 @@ IdentifierNamingCheck::getFailureInfo(
                  << llvm::formatv(": unable to split words for {0} '{1}'\n",
                                   KindName, Name));
     }
-    return None;
+    return std::nullopt;
   }
   return RenamerClangTidyCheck::FailureInfo{std::move(KindName),
                                             std::move(Fixup)};
@@ -1395,7 +1395,7 @@ IdentifierNamingCheck::getDeclFailureInfo(const NamedDecl *Decl,
   SourceLocation Loc = Decl->getLocation();
   const FileStyle &FileStyle = getStyleForFile(SM.getFilename(Loc));
   if (!FileStyle.isActive())
-    return llvm::None;
+    return std::nullopt;
 
   return getFailureInfo(HungarianNotation.getDeclTypeName(Decl),
                         Decl->getName(), Decl, Loc, FileStyle.getStyles(),
@@ -1411,7 +1411,7 @@ IdentifierNamingCheck::getMacroFailureInfo(const Token &MacroNameTok,
   SourceLocation Loc = MacroNameTok.getLocation();
   const FileStyle &Style = getStyleForFile(SM.getFilename(Loc));
   if (!Style.isActive())
-    return llvm::None;
+    return std::nullopt;
 
   return getFailureInfo("", MacroNameTok.getIdentifierInfo()->getName(),
                         nullptr, Loc, Style.getStyles(), Style.getHNOption(),

diff  --git a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
index 38e4272388642..45f3ea6c68125 100644
--- a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
@@ -110,10 +110,10 @@ declRanges(const DeclStmt *DS, const SourceManager &SM,
            const LangOptions &LangOpts) {
   std::size_t DeclCount = std::distance(DS->decl_begin(), DS->decl_end());
   if (DeclCount < 2)
-    return None;
+    return std::nullopt;
 
   if (rangeContainsExpansionsOrDirectives(DS->getSourceRange(), SM, LangOpts))
-    return None;
+    return std::nullopt;
 
   // The initial type of the declaration and each declaration has it's own
   // slice. This is necessary, because pointers and references bind only
@@ -127,12 +127,12 @@ declRanges(const DeclStmt *DS, const SourceManager &SM,
   const auto *FirstDecl = dyn_cast<VarDecl>(*DS->decl_begin());
 
   if (FirstDecl == nullptr)
-    return None;
+    return std::nullopt;
 
   // FIXME: Member pointers are not transformed correctly right now, that's
   // why they are treated as problematic here.
   if (typeIsMemberPointer(FirstDecl->getType().IgnoreParens().getTypePtr()))
-    return None;
+    return std::nullopt;
 
   // Consider the following case: 'int * pointer, value = 42;'
   // Created slices (inclusive)    [  ][       ] [         ]
@@ -168,7 +168,7 @@ declRanges(const DeclStmt *DS, const SourceManager &SM,
 
   SourceRange DeclRange(DS->getBeginLoc(), Start);
   if (DeclRange.isInvalid() || isMacroID(DeclRange))
-    return None;
+    return std::nullopt;
 
   // The first slice, that is prepended to every isolated declaration, is
   // created.
@@ -182,7 +182,7 @@ declRanges(const DeclStmt *DS, const SourceManager &SM,
     // FIXME: Member pointers are not transformed correctly right now, that's
     // why they are treated as problematic here.
     if (typeIsMemberPointer(CurrentDecl->getType().IgnoreParens().getTypePtr()))
-      return None;
+      return std::nullopt;
 
     SourceLocation DeclEnd =
         CurrentDecl->hasInit()
@@ -192,7 +192,7 @@ declRanges(const DeclStmt *DS, const SourceManager &SM,
 
     SourceRange VarNameRange(DeclBegin, DeclEnd);
     if (VarNameRange.isInvalid() || isMacroID(VarNameRange))
-      return None;
+      return std::nullopt;
 
     Slices.emplace_back(VarNameRange);
     DeclBegin = DeclEnd.getLocWithOffset(1);
@@ -212,14 +212,14 @@ collectSourceRanges(llvm::ArrayRef<SourceRange> Ranges, const SourceManager &SM,
         LangOpts);
 
     if (CharRange.isInvalid())
-      return None;
+      return std::nullopt;
 
     bool InvalidText = false;
     StringRef Snippet =
         Lexer::getSourceText(CharRange, SM, LangOpts, &InvalidText);
 
     if (InvalidText)
-      return None;
+      return std::nullopt;
 
     Snippets.emplace_back(Snippet);
   }

diff  --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 2de4ccd1b4efa..7ee48389c3c13 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -73,7 +73,7 @@ getNamespaceNameAsWritten(SourceLocation &Loc, const SourceManager &Sources,
       } else if (T->is(tok::coloncolon)) {
         Result.append("::");
       } else { // Any other kind of token is unexpected here.
-        return llvm::None;
+        return std::nullopt;
       }
     }
   }

diff  --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
index c564b5adcbbf8..e25d1474ffdd0 100644
--- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
@@ -48,7 +48,7 @@ llvm::Optional<Token> findQualToken(const VarDecl *Decl, Qualifier Qual,
       Result.Context->getLangOpts());
 
   if (FileRange.isInvalid())
-    return llvm::None;
+    return std::nullopt;
 
   tok::TokenKind Tok =
       Qual == Qualifier::Const
@@ -70,7 +70,7 @@ getTypeSpecifierLocation(const VarDecl *Var,
 
   if (TypeSpecifier.getBegin().isMacroID() ||
       TypeSpecifier.getEnd().isMacroID())
-    return llvm::None;
+    return std::nullopt;
   return TypeSpecifier;
 }
 
@@ -78,11 +78,11 @@ llvm::Optional<SourceRange> mergeReplacementRange(SourceRange &TypeSpecifier,
                                                   const Token &ConstToken) {
   if (TypeSpecifier.getBegin().getLocWithOffset(-1) == ConstToken.getEndLoc()) {
     TypeSpecifier.setBegin(ConstToken.getLocation());
-    return llvm::None;
+    return std::nullopt;
   }
   if (TypeSpecifier.getEnd().getLocWithOffset(1) == ConstToken.getLocation()) {
     TypeSpecifier.setEnd(ConstToken.getEndLoc());
-    return llvm::None;
+    return std::nullopt;
   }
   return SourceRange(ConstToken.getLocation(), ConstToken.getEndLoc());
 }

diff  --git a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index a6e71e6afae55..d1537eba99f7d 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -50,7 +50,7 @@ getConstructExprArgRange(const CXXConstructExpr &Construct) {
       E = Arg->getEndLoc();
   }
   if (B.isInvalid() || E.isInvalid())
-    return llvm::None;
+    return std::nullopt;
   return SourceRange(B, E);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index d78b5c53a10dc..1f1d605175a3f 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -300,18 +300,18 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
   static Optional<bool> getAsBoolLiteral(const Expr *E, bool FilterMacro) {
     if (const auto *Bool = dyn_cast<CXXBoolLiteralExpr>(E)) {
       if (FilterMacro && Bool->getBeginLoc().isMacroID())
-        return llvm::None;
+        return std::nullopt;
       return Bool->getValue();
     }
     if (const auto *UnaryOp = dyn_cast<UnaryOperator>(E)) {
       if (FilterMacro && UnaryOp->getBeginLoc().isMacroID())
-        return None;
+        return std::nullopt;
       if (UnaryOp->getOpcode() == UO_LNot)
         if (Optional<bool> Res = getAsBoolLiteral(
                 UnaryOp->getSubExpr()->IgnoreImplicit(), FilterMacro))
           return !*Res;
     }
-    return llvm::None;
+    return std::nullopt;
   }
 
   template <typename Node> struct NodeAndBool {

diff  --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
index 4841da5673506..2a5e614584fb9 100644
--- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
@@ -587,7 +587,7 @@ Optional<int8_t> SuspiciousCallArgumentCheck::getBound(Heuristic H,
   assert(Idx < HeuristicCount);
 
   if (!Defaults[Idx].hasBounds())
-    return None;
+    return std::nullopt;
 
   switch (BK) {
   case BoundKind::DissimilarBelow:

diff  --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index 0b1f3ddbe0c2f..ee760f7c1ade7 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -67,11 +67,11 @@ llvm::Optional<SourceLocation> getMacroAwareLocation(SourceLocation Loc,
                                                      const SourceManager &SM) {
   // Do nothing if the provided location is invalid.
   if (Loc.isInvalid())
-    return llvm::None;
+    return std::nullopt;
   // Look where the location was *actually* written.
   SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
   if (SpellingLoc.isInvalid())
-    return llvm::None;
+    return std::nullopt;
   return SpellingLoc;
 }
 
@@ -81,7 +81,7 @@ llvm::Optional<SourceRange> getMacroAwareSourceRange(SourceRange Loc,
       getMacroAwareLocation(Loc.getBegin(), SM);
   llvm::Optional<SourceLocation> End = getMacroAwareLocation(Loc.getEnd(), SM);
   if (!Begin || !End)
-    return llvm::None;
+    return std::nullopt;
   return SourceRange(*Begin, *End);
 }
 
@@ -100,7 +100,7 @@ getNewSuffix(llvm::StringRef OldSuffix,
   if (NewSuffix != NewSuffixes.end())
     return NewSuffix->str();
   // Nope, I guess we have to keep it as-is.
-  return llvm::None;
+  return std::nullopt;
 }
 
 template <typename LiteralType>
@@ -123,7 +123,7 @@ shouldReplaceLiteralSuffix(const Expr &Literal,
   llvm::Optional<SourceRange> Range =
       getMacroAwareSourceRange(ReplacementDsc.LiteralLocation, SM);
   if (!Range)
-    return llvm::None;
+    return std::nullopt;
 
   if (RangeCanBeFixed)
     ReplacementDsc.LiteralLocation = *Range;
@@ -138,7 +138,7 @@ shouldReplaceLiteralSuffix(const Expr &Literal,
   // Make sure the first character is actually a digit, instead of
   // something else, like a non-type template parameter.
   if (!std::isdigit(static_cast<unsigned char>(LiteralSourceText.front())))
-    return llvm::None;
+    return std::nullopt;
 
   size_t Skip = 0;
 
@@ -161,7 +161,7 @@ shouldReplaceLiteralSuffix(const Expr &Literal,
   // We can't check whether the *Literal has any suffix or not without actually
   // looking for the suffix. So it is totally possible that there is no suffix.
   if (Skip == StringRef::npos)
-    return llvm::None;
+    return std::nullopt;
 
   // Move the cursor in the source range to the beginning of the suffix.
   Range->setBegin(Range->getBegin().getLocWithOffset(Skip));
@@ -174,7 +174,7 @@ shouldReplaceLiteralSuffix(const Expr &Literal,
   llvm::Optional<std::string> NewSuffix =
       getNewSuffix(ReplacementDsc.OldSuffix, NewSuffixes);
   if (!NewSuffix || ReplacementDsc.OldSuffix == *NewSuffix)
-    return llvm::None; // The suffix was already the way it should be.
+    return std::nullopt; // The suffix was already the way it should be.
 
   if (RangeCanBeFixed)
     ReplacementDsc.FixIt = FixItHint::CreateReplacement(*Range, *NewSuffix);

diff  --git a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
index f7b4c3ef57938..07c9eb0f00985 100644
--- a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -57,10 +57,10 @@ llvm::Optional<StringRef>
 getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions) {
   StringRef Extension = llvm::sys::path::extension(FileName);
   if (Extension.empty())
-    return llvm::None;
+    return std::nullopt;
   // Skip "." prefix.
   if (!FileExtensions.count(Extension.substr(1)))
-    return llvm::None;
+    return std::nullopt;
   return Extension;
 }
 

diff  --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index dd7c24d0c7ef7..546efd5ce5a29 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -44,7 +44,7 @@ static bool locDangerous(SourceLocation S) {
 static Optional<SourceLocation>
 skipLParensBackwards(SourceLocation Start, const ASTContext &Context) {
   if (locDangerous(Start))
-    return None;
+    return std::nullopt;
 
   auto PreviousTokenLParen = [&Start, &Context]() {
     Token T;
@@ -58,14 +58,14 @@ skipLParensBackwards(SourceLocation Start, const ASTContext &Context) {
                                           Context.getLangOpts());
 
   if (locDangerous(Start))
-    return None;
+    return std::nullopt;
   return Start;
 }
 
 static Optional<FixItHint> fixIfNotDangerous(SourceLocation Loc,
                                              StringRef Text) {
   if (locDangerous(Loc))
-    return None;
+    return std::nullopt;
   return FixItHint::CreateInsertion(Loc, Text);
 }
 
@@ -93,7 +93,7 @@ static Optional<FixItHint> changeValue(const VarDecl &Var,
 
     if (IgnoredParens)
       return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier));
-    return None;
+    return std::nullopt;
   }
   llvm_unreachable("Unknown QualifierPolicy enum");
 }
@@ -102,13 +102,13 @@ static Optional<FixItHint> changePointerItself(const VarDecl &Var,
                                                DeclSpec::TQ Qualifier,
                                                const ASTContext &Context) {
   if (locDangerous(Var.getLocation()))
-    return None;
+    return std::nullopt;
 
   Optional<SourceLocation> IgnoredParens =
       skipLParensBackwards(Var.getLocation(), Context);
   if (IgnoredParens)
     return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier));
-  return None;
+  return std::nullopt;
 }
 
 static Optional<FixItHint>
@@ -136,7 +136,7 @@ changePointer(const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee,
           Var.getLocation(), Context.getSourceManager(), Context.getLangOpts(),
           tok::star);
       if (locDangerous(BeforeStar))
-        return None;
+        return std::nullopt;
 
       Optional<SourceLocation> IgnoredParens =
           skipLParensBackwards(BeforeStar, Context);
@@ -144,7 +144,7 @@ changePointer(const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee,
       if (IgnoredParens)
         return fixIfNotDangerous(*IgnoredParens,
                                  buildQualifier(Qualifier, true));
-      return None;
+      return std::nullopt;
     }
   }
 
@@ -159,7 +159,7 @@ changePointer(const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee,
     return fixIfNotDangerous(BeforeStar, buildQualifier(Qualifier, true));
   }
 
-  return None;
+  return std::nullopt;
 }
 
 static Optional<FixItHint>
@@ -178,7 +178,7 @@ changeReferencee(const VarDecl &Var, DeclSpec::TQ Qualifier, QualType Pointee,
   if (IgnoredParens)
     return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier, true));
 
-  return None;
+  return std::nullopt;
 }
 
 Optional<FixItHint> addQualifierToVarDecl(const VarDecl &Var,
@@ -221,7 +221,7 @@ Optional<FixItHint> addQualifierToVarDecl(const VarDecl &Var,
                            QualTarget, QualPolicy, Context);
   }
 
-  return None;
+  return std::nullopt;
 }
 } // namespace fixit
 } // namespace utils

diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index 144ebdf5dbbfe..08bbe9deca406 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -71,13 +71,13 @@ llvm::Optional<FixItHint>
 IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
   bool IsAngled = Header.consume_front("<");
   if (IsAngled != Header.consume_back(">"))
-    return llvm::None;
+    return std::nullopt;
   // We assume the same Header will never be included both angled and not
   // angled.
   // In self contained diags mode we don't track what headers we have already
   // inserted.
   if (!SelfContainedDiags && !InsertedHeaders[FileID].insert(Header).second)
-    return llvm::None;
+    return std::nullopt;
 
   return getOrCreate(FileID).createIncludeInsertion(Header, IsAngled);
 }

diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index 8d620ca3af681..fc26d966c88ef 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -179,7 +179,7 @@ Optional<FixItHint> IncludeSorter::createIncludeInsertion(StringRef FileName,
         return FixItHint::CreateInsertion(Location.getBegin(), IncludeStmt);
       }
       if (FileName == IncludeEntry) {
-        return llvm::None;
+        return std::nullopt;
       }
     }
     // FileName comes after all include entries in bucket, insert it after
@@ -203,7 +203,7 @@ Optional<FixItHint> IncludeSorter::createIncludeInsertion(StringRef FileName,
     }
   }
   if (NonEmptyKind == IK_InvalidInclude) {
-    return llvm::None;
+    return std::nullopt;
   }
 
   if (NonEmptyKind < IncludeKind) {

diff  --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
index f769db8840f79..6ab48afc7d20a 100644
--- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -138,7 +138,7 @@ llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
     if (Tok.is(tok::less))
       SawTemplate = true;
     else if (Tok.isOneOf(tok::greater, tok::greatergreater))
-      LastMatchAfterTemplate = None;
+      LastMatchAfterTemplate = std::nullopt;
     else if (Tok.is(TK)) {
       if (SawTemplate)
         LastMatchAfterTemplate = Tok;
@@ -146,8 +146,8 @@ llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
         LastMatchBeforeTemplate = Tok;
     }
   }
-  return LastMatchAfterTemplate != None ? LastMatchAfterTemplate
-                                        : LastMatchBeforeTemplate;
+  return LastMatchAfterTemplate != std::nullopt ? LastMatchAfterTemplate
+                                                : LastMatchBeforeTemplate;
 }
 
 static bool breakAndReturnEnd(const Stmt &S) {

diff  --git a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
index 82f103a02771e..fcefdc32024ca 100644
--- a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
+++ b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
@@ -32,10 +32,10 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement,
                               const std::vector<std::string> &Abbreviations) {
   const FunctionDecl *Function = getSurroundingFunction(Context, Statement);
   if (!Function || !Function->hasBody())
-    return None;
+    return std::nullopt;
 
   if (AddedAliases[Function].count(Namespace.str()) != 0)
-    return None;
+    return std::nullopt;
 
   // FIXME: Doesn't consider the order of declarations.
   // If we accidentally pick an alias defined later in the function,
@@ -51,7 +51,7 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement,
 
   if (ExistingAlias != nullptr) {
     AddedAliases[Function][Namespace.str()] = ExistingAlias->getName().str();
-    return None;
+    return std::nullopt;
   }
 
   for (const auto &Abbreviation : Abbreviations) {
@@ -75,7 +75,7 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement,
     return FixItHint::CreateInsertion(Loc, Declaration);
   }
 
-  return None;
+  return std::nullopt;
 }
 
 std::string NamespaceAliaser::getNamespaceName(ASTContext &Context,

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index ba1f4d4ebe2ef..449b0569537c2 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -258,12 +258,12 @@ NameLookup findDeclInBases(const CXXRecordDecl &Parent, StringRef DeclName,
       if (*Search) {
         if (Found)
           return NameLookup(
-              llvm::None); // Multiple decls found in 
diff erent base classes.
+              std::nullopt); // Multiple decls found in 
diff erent base classes.
         Found = *Search;
         continue;
       }
     } else
-      return NameLookup(llvm::None); // Propagate multiple resolution back up.
+      return NameLookup(std::nullopt); // Propagate multiple resolution back up.
   }
   return NameLookup(Found); // If nullptr, decl wasn't found.
 }

diff  --git a/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp b/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
index 0735587766559..ef897da98146c 100644
--- a/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
+++ b/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
@@ -41,7 +41,7 @@ bool hasDeletedCopyConstructor(QualType Type) {
 llvm::Optional<bool> isExpensiveToCopy(QualType Type,
                                        const ASTContext &Context) {
   if (Type->isDependentType() || Type->isIncompleteType())
-    return llvm::None;
+    return std::nullopt;
   return !Type.isTriviallyCopyableType(Context) &&
          !classHasTrivialCopyAndDestroy(Type) &&
          !hasDeletedCopyConstructor(Type) &&

diff  --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
index e852532af418d..480612c9140c2 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
@@ -34,17 +34,17 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
   StringRef UnqualifiedName = getUnqualifiedName(QualifiedName);
   const FunctionDecl *Function = getSurroundingFunction(Context, Statement);
   if (!Function)
-    return None;
+    return std::nullopt;
 
   if (AddedUsing.count(std::make_pair(Function, QualifiedName.str())) != 0)
-    return None;
+    return std::nullopt;
 
   SourceLocation InsertLoc = Lexer::getLocForEndOfToken(
       Function->getBody()->getBeginLoc(), 0, SourceMgr, Context.getLangOpts());
 
   // Only use using declarations in the main file, not in includes.
   if (SourceMgr.getFileID(InsertLoc) != SourceMgr.getMainFileID())
-    return None;
+    return std::nullopt;
 
   // FIXME: This declaration could be masked. Investigate if
   // there is a way to avoid using Sema.
@@ -55,7 +55,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
            .empty();
   if (AlreadyHasUsingDecl) {
     AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
-    return None;
+    return std::nullopt;
   }
   // Find conflicting declarations and references.
   auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
@@ -65,7 +65,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
       !match(findAll(declRefExpr(to(ConflictingDecl))), *Function, Context)
            .empty();
   if (HasConflictingDeclaration || HasConflictingDeclRef)
-    return None;
+    return std::nullopt;
 
   std::string Declaration =
       (llvm::Twine("\nusing ") + QualifiedName + ";").str();


        


More information about the cfe-commits mailing list