Author: Kazu Hirata Date: 2022-12-07T20:22:27-08:00 New Revision: aee591003c0c1d2eb7f3e038aade820dab20d849
URL: https://github.com/llvm/llvm-project/commit/aee591003c0c1d2eb7f3e038aade820dab20d849 DIFF: https://github.com/llvm/llvm-project/commit/aee591003c0c1d2eb7f3e038aade820dab20d849.diff LOG: [clang-tools-extra] Use std::nullopt instead of None in comments (NFC) This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Added: Modified: clang-tools-extra/clang-tidy/ClangTidyCheck.h 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/DurationRewriter.h clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp clang-tools-extra/clang-tidy/utils/LexerUtils.h clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/Headers.h Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index cb5933652a480..86a5fc4c2ae7d 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -169,7 +169,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// Reads the option with the check-local name \p LocalName from local or /// global ``CheckOptions``. Gets local option first. If local is not /// present, falls back to get global option. If global option is not - /// present either, return ``None``. + /// present either, return ``std::nullopt``. llvm::Optional<StringRef> getLocalOrGlobal(StringRef LocalName) const; /// Read a named option from the ``Context``. @@ -185,10 +185,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present, return - /// ``None``. + /// ``std::nullopt``. /// /// If the corresponding key can't be parsed as a ``T``, emit a - /// diagnostic and return ``None``. + /// diagnostic and return ``std::nullopt``. template <typename T> std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>> get(StringRef LocalName) const { @@ -222,10 +222,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// Reads the option with the check-local name \p LocalName from local or /// global ``CheckOptions``. Gets local option first. If local is not /// present, falls back to get global option. If global option is not - /// present either, return ``None``. + /// present either, return ``std::nullopt``. /// /// If the corresponding key can't be parsed as a ``T``, emit a - /// diagnostic and return ``None``. + /// diagnostic and return ``std::nullopt``. template <typename T> std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>> getLocalOrGlobal(StringRef LocalName) const { @@ -266,10 +266,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present, return - /// ``None``. + /// ``std::nullopt``. /// /// If the corresponding key can't be parsed as a ``T``, emit a - /// diagnostic and return ``None``. + /// diagnostic and return ``std::nullopt``. /// /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. @@ -306,10 +306,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// Reads the option with the check-local name \p LocalName from local or /// global ``CheckOptions``. Gets local option first. If local is not /// present, falls back to get global option. If global option is not - /// present either, returns ``None``. + /// present either, returns ``std::nullopt``. /// /// If the corresponding key can't be parsed as a ``T``, emit a - /// diagnostic and return ``None``. + /// diagnostic and return ``std::nullopt``. /// /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. @@ -428,10 +428,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { /// /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present, return -/// ``None``. +/// ``std::nullopt``. /// /// If the corresponding key can't be parsed as a bool, emit a -/// diagnostic and return ``None``. +/// diagnostic and return ``std::nullopt``. template <> llvm::Optional<bool> ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const; diff --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp index 076e8fd2f625f..d9c5302bd2daf 100644 --- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp +++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp @@ -45,7 +45,7 @@ namespace tidy { enum class NoLintType { NoLint, NoLintNextLine, NoLintBegin, NoLintEnd }; // Convert a string like "NOLINTNEXTLINE" to its enum `Type::NoLintNextLine`. -// Return `None` if the string is unrecognized. +// Return `std::nullopt` if the string is unrecognized. static Optional<NoLintType> strToNoLintType(StringRef Str) { auto Type = llvm::StringSwitch<Optional<NoLintType>>(Str) .Case("NOLINT", NoLintType::NoLint) diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp index 17ec54e587b4e..1e5ce5331f081 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp @@ -20,7 +20,7 @@ namespace abseil { // Given the name of a duration factory function, return the appropriate // `DurationScale` for that factory. If no factory can be found for -// `FactoryName`, return `None`. +// `FactoryName`, return `std::nullopt`. static llvm::Optional<DurationScale> getScaleForFactory(llvm::StringRef FactoryName) { return llvm::StringSwitch<llvm::Optional<DurationScale>>(FactoryName) @@ -93,7 +93,7 @@ getNewScaleSingleStep(DurationScale OldScale, double Multiplier) { } // Given the scale of a duration and a `Multiplier`, determine if `Multiplier` -// would produce a new scale. If so, return it, otherwise `None`. +// would produce a new scale. If so, return it, otherwise `std::nullopt`. static llvm::Optional<DurationScale> getNewScale(DurationScale OldScale, double Multiplier) { while (Multiplier != 1.0) { diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp index 48000482ce240..ce012653941d4 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp @@ -68,7 +68,7 @@ getDurationInverseForScale(DurationScale Scale) { } /// If `Node` is a call to the inverse of `Scale`, return that inverse's -/// argument, otherwise None. +/// argument, otherwise std::nullopt. static llvm::Optional<std::string> rewriteInverseDurationCall(const MatchFinder::MatchResult &Result, DurationScale Scale, const Expr &Node) { @@ -87,7 +87,7 @@ rewriteInverseDurationCall(const MatchFinder::MatchResult &Result, } /// If `Node` is a call to the inverse of `Scale`, return that inverse's -/// argument, otherwise None. +/// argument, otherwise std::nullopt. static llvm::Optional<std::string> rewriteInverseTimeCall(const MatchFinder::MatchResult &Result, DurationScale Scale, const Expr &Node) { diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h index 0803a7a4c0e02..14126072a12ea 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h @@ -50,7 +50,7 @@ stripFloatCast(const ast_matchers::MatchFinder::MatchResult &Result, /// Possibly remove the fractional part of a floating point literal. /// /// If `Node` represents a floating point literal with a zero fractional part, -/// return the textual context of the integral part, otherwise `None`. +/// return the textual context of the integral part, otherwise `std::nullopt`. llvm::Optional<std::string> stripFloatLiteralFraction(const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node); @@ -63,11 +63,11 @@ simplifyDurationFactoryArg(const ast_matchers::MatchFinder::MatchResult &Result, const Expr &Node); /// Given the name of an inverse Duration function (e.g., `ToDoubleSeconds`), -/// return its `DurationScale`, or `None` if a match is not found. +/// return its `DurationScale`, or `std::nullopt` if a match is not found. llvm::Optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name); /// Given the name of an inverse Time function (e.g., `ToUnixSeconds`), -/// return its `DurationScale`, or `None` if a match is not found. +/// return its `DurationScale`, or `std::nullopt` if a match is not found. llvm::Optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name); /// Given a `Scale` return the fully qualified inverse functions for it. diff --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp index 412d0093b76b1..0c9bda79006f4 100644 --- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp @@ -21,9 +21,9 @@ namespace tidy { namespace readability { // Finds the location of the qualifying `const` token in the `FunctionDecl`'s -// return type. Returns `None` when the return type is not `const`-qualified or -// `const` does not appear in `Def`'s source, like when the type is an alias or -// a macro. +// return type. Returns `std::nullopt` when the return type is not +// `const`-qualified or `const` does not appear in `Def`'s source, like when the +// type is an alias or a macro. static llvm::Optional<Token> findConstToRemove(const FunctionDecl *Def, const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.h b/clang-tools-extra/clang-tidy/utils/LexerUtils.h index 79ba16ded9680..b8e0f6ae2f7fc 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.h +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.h @@ -99,8 +99,8 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range, /// Assuming that ``Range`` spans a CVR-qualified type, returns the /// token in ``Range`` that is responsible for the qualification. ``Range`` -/// must be valid with respect to ``SM``. Returns ``None`` if no qualifying -/// tokens are found. +/// must be valid with respect to ``SM``. Returns ``std::nullopt`` if no +/// qualifying tokens are found. /// \note: doesn't support member function qualifiers. llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK, CharSourceRange Range, diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h index 38ca2011fba14..c52fce5aa8fe5 100644 --- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h @@ -44,8 +44,8 @@ class TransformerClangTidyCheck : public ClangTidyCheck { /// \c setRule. /// /// \p MakeRule generates the rewrite rule to be used by the check, based on - /// the given language and clang-tidy options. It can return \c None to handle - /// cases where the options disable the check. + /// the given language and clang-tidy options. It can return \c std::nullopt + /// to handle cases where the options disable the check. /// /// See \c setRule for constraints on the rule. TransformerClangTidyCheck( diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h b/clang-tools-extra/clangd/ClangdLSPServer.h index 351b3d0da0be7..c942848f769d5 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.h +++ b/clang-tools-extra/clangd/ClangdLSPServer.h @@ -42,7 +42,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks, /// Look for compilation databases, rather than using compile commands /// set via LSP (extensions) only. bool UseDirBasedCDB = true; - /// The offset-encoding to use, or None to negotiate it over LSP. + /// The offset-encoding to use, or std::nullopt to negotiate it over LSP. llvm::Optional<OffsetEncoding> Encoding; /// If set, periodically called to release memory. /// Consider malloc_trim(3) diff --git a/clang-tools-extra/clangd/Headers.h b/clang-tools-extra/clangd/Headers.h index 5611b32b11aa1..fd739845cdd84 100644 --- a/clang-tools-extra/clangd/Headers.h +++ b/clang-tools-extra/clangd/Headers.h @@ -240,8 +240,8 @@ class IncludeInserter { /// \param IncludingFile is the absolute path of the file that InsertedHeader /// will be inserted. /// - /// \return A quoted "path" or <path> to be included, or None if it couldn't - /// be shortened. + /// \return A quoted "path" or <path> to be included, or std::nullopt if it + /// couldn't be shortened. llvm::Optional<std::string> calculateIncludePath(const HeaderFile &InsertedHeader, llvm::StringRef IncludingFile) const; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits