addr2line updated this revision to Diff 482424. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139919/new/
https://reviews.llvm.org/D139919 Files: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp clang-tools-extra/clang-tidy/ClangTidyCheck.h clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h llvm/include/llvm/Support/YAMLParser.h llvm/lib/Support/YAMLParser.cpp llvm/lib/Support/YAMLTraits.cpp
Index: llvm/lib/Support/YAMLTraits.cpp =================================================================== --- llvm/lib/Support/YAMLTraits.cpp +++ llvm/lib/Support/YAMLTraits.cpp @@ -886,7 +886,7 @@ } StringRef ScalarTraits<bool>::input(StringRef Scalar, void *, bool &Val) { - if (llvm::Optional<bool> Parsed = parseBool(Scalar)) { + if (std::optional<bool> Parsed = parseBool(Scalar)) { Val = *Parsed; return StringRef(); } Index: llvm/lib/Support/YAMLParser.cpp =================================================================== --- llvm/lib/Support/YAMLParser.cpp +++ llvm/lib/Support/YAMLParser.cpp @@ -760,7 +760,7 @@ return EscapedInput; } -llvm::Optional<bool> yaml::parseBool(StringRef S) { +std::optional<bool> yaml::parseBool(StringRef S) { switch (S.size()) { case 1: switch (S.front()) { Index: llvm/include/llvm/Support/YAMLParser.h =================================================================== --- llvm/include/llvm/Support/YAMLParser.h +++ llvm/include/llvm/Support/YAMLParser.h @@ -45,6 +45,7 @@ #include <iterator> #include <map> #include <memory> +#include <optional> #include <string> #include <system_error> @@ -78,7 +79,7 @@ std::string escape(StringRef Input, bool EscapePrintable = true); /// Parse \p S as a bool according to https://yaml.org/type/bool.html. -llvm::Optional<bool> parseBool(StringRef S); +std::optional<bool> parseBool(StringRef S); /// This class represents a YAML stream potentially containing multiple /// documents. Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -10,7 +10,7 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERNAMINGCHECK_H #include "../utils/RenamerClangTidyCheck.h" -#include "llvm/ADT/Optional.h" +#include <optional> namespace clang { namespace tidy { namespace readability { @@ -57,7 +57,7 @@ struct HungarianNotationOption { HungarianNotationOption() : HPType(HungarianPrefixType::HPT_Off) {} - llvm::Optional<CaseType> Case; + std::optional<CaseType> Case; HungarianPrefixType HPType; llvm::StringMap<std::string> General; llvm::StringMap<std::string> CString; @@ -69,14 +69,14 @@ struct NamingStyle { NamingStyle() = default; - NamingStyle(llvm::Optional<CaseType> Case, const std::string &Prefix, + NamingStyle(std::optional<CaseType> Case, const std::string &Prefix, const std::string &Suffix, const std::string &IgnoredRegexpStr, HungarianPrefixType HPType); NamingStyle(const NamingStyle &O) = delete; NamingStyle &operator=(NamingStyle &&O) = default; NamingStyle(NamingStyle &&O) = default; - llvm::Optional<CaseType> Case; + std::optional<CaseType> Case; std::string Prefix; std::string Suffix; // Store both compiled and non-compiled forms so original value can be @@ -120,12 +120,12 @@ struct FileStyle { FileStyle() : IsActive(false), IgnoreMainLikeFunctions(false) {} - FileStyle(SmallVectorImpl<Optional<NamingStyle>> &&Styles, + FileStyle(SmallVectorImpl<std::optional<NamingStyle>> &&Styles, HungarianNotationOption HNOption, bool IgnoreMainLike) : Styles(std::move(Styles)), HNOption(std::move(HNOption)), IsActive(true), IgnoreMainLikeFunctions(IgnoreMainLike) {} - ArrayRef<Optional<NamingStyle>> getStyles() const { + ArrayRef<std::optional<NamingStyle>> getStyles() const { assert(IsActive); return Styles; } @@ -139,7 +139,7 @@ bool isIgnoringMainLikeFunction() const { return IgnoreMainLikeFunctions; } private: - SmallVector<Optional<NamingStyle>, 0> Styles; + SmallVector<std::optional<NamingStyle>, 0> Styles; HungarianNotationOption HNOption; bool IsActive; bool IgnoreMainLikeFunctions; @@ -168,13 +168,13 @@ StyleKind findStyleKind( const NamedDecl *D, - ArrayRef<llvm::Optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, + ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, bool IgnoreMainLikeFunctions) const; - llvm::Optional<RenamerClangTidyCheck::FailureInfo> getFailureInfo( + std::optional<RenamerClangTidyCheck::FailureInfo> getFailureInfo( StringRef Type, StringRef Name, const NamedDecl *ND, SourceLocation Location, - ArrayRef<llvm::Optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, + ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, const IdentifierNamingCheck::HungarianNotationOption &HNOption, StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) const; @@ -182,10 +182,10 @@ bool IncludeMainLike) const; private: - llvm::Optional<FailureInfo> + std::optional<FailureInfo> getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const override; - llvm::Optional<FailureInfo> + std::optional<FailureInfo> getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const override; DiagInfo getDiagInfo(const NamingCheckId &ID, Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -228,7 +228,7 @@ // clang-format on IdentifierNamingCheck::NamingStyle::NamingStyle( - llvm::Optional<IdentifierNamingCheck::CaseType> Case, + std::optional<IdentifierNamingCheck::CaseType> Case, const std::string &Prefix, const std::string &Suffix, const std::string &IgnoredRegexpStr, HungarianPrefixType HPType) : Case(Case), Prefix(Prefix), Suffix(Suffix), @@ -249,7 +249,7 @@ HungarianNotation.loadDefaultConfig(HNOption); HungarianNotation.loadFileConfig(Options, HNOption); - SmallVector<llvm::Optional<IdentifierNamingCheck::NamingStyle>, 0> Styles; + SmallVector<std::optional<IdentifierNamingCheck::NamingStyle>, 0> Styles; Styles.resize(SK_Count); SmallString<64> StyleString; for (unsigned I = 0; I < SK_Count; ++I) { @@ -424,7 +424,7 @@ if (Iter == StrMap.end()) return false; - llvm::Optional<bool> Parsed = llvm::yaml::parseBool(Iter->getValue()); + std::optional<bool> Parsed = llvm::yaml::parseBool(Iter->getValue()); return *Parsed; } @@ -802,7 +802,7 @@ void IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { RenamerClangTidyCheck::storeOptions(Opts); SmallString<64> StyleString; - ArrayRef<llvm::Optional<NamingStyle>> Styles = MainFileStyle->getStyles(); + ArrayRef<std::optional<NamingStyle>> Styles = MainFileStyle->getStyles(); for (size_t I = 0; I < SK_Count; ++I) { if (!Styles[I]) continue; @@ -1068,7 +1068,7 @@ StyleKind IdentifierNamingCheck::findStyleKind( const NamedDecl *D, - ArrayRef<llvm::Optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, + ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, bool IgnoreMainLikeFunctions) const { assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() && "Decl must be an explicit identifier with a name."); @@ -1353,11 +1353,11 @@ return SK_Invalid; } -llvm::Optional<RenamerClangTidyCheck::FailureInfo> +std::optional<RenamerClangTidyCheck::FailureInfo> IdentifierNamingCheck::getFailureInfo( StringRef Type, StringRef Name, const NamedDecl *ND, SourceLocation Location, - ArrayRef<llvm::Optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, + ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles, const IdentifierNamingCheck::HungarianNotationOption &HNOption, StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) const { if (SK == SK_Invalid || !NamingStyles[SK]) @@ -1389,7 +1389,7 @@ std::move(Fixup)}; } -llvm::Optional<RenamerClangTidyCheck::FailureInfo> +std::optional<RenamerClangTidyCheck::FailureInfo> IdentifierNamingCheck::getDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const { SourceLocation Loc = Decl->getLocation(); @@ -1405,7 +1405,7 @@ SM, IgnoreFailedSplit); } -llvm::Optional<RenamerClangTidyCheck::FailureInfo> +std::optional<RenamerClangTidyCheck::FailureInfo> IdentifierNamingCheck::getMacroFailureInfo(const Token &MacroNameTok, const SourceManager &SM) const { SourceLocation Loc = MacroNameTok.getLocation(); Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -13,7 +13,7 @@ #include "ClangTidyOptions.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Basic/Diagnostic.h" -#include "llvm/ADT/Optional.h" +#include <optional> #include <type_traits> #include <utility> #include <vector> @@ -155,7 +155,7 @@ /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present, return /// ``std::nullopt``. - llvm::Optional<StringRef> get(StringRef LocalName) const; + std::optional<StringRef> get(StringRef LocalName) const; /// Read a named option from the ``Context``. /// @@ -170,7 +170,7 @@ /// 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 ``std::nullopt``. - llvm::Optional<StringRef> getLocalOrGlobal(StringRef LocalName) const; + std::optional<StringRef> getLocalOrGlobal(StringRef LocalName) const; /// Read a named option from the ``Context``. /// @@ -190,9 +190,9 @@ /// If the corresponding key can't be parsed as a ``T``, emit a /// diagnostic and return ``std::nullopt``. template <typename T> - std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>> + std::enable_if_t<std::is_integral<T>::value, std::optional<T>> get(StringRef LocalName) const { - if (llvm::Optional<StringRef> Value = get(LocalName)) { + if (std::optional<StringRef> Value = get(LocalName)) { T Result{}; if (!StringRef(*Value).getAsInteger(10, Result)) return Result; @@ -227,9 +227,9 @@ /// If the corresponding key can't be parsed as a ``T``, emit a /// diagnostic and return ``std::nullopt``. template <typename T> - std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>> + std::enable_if_t<std::is_integral<T>::value, std::optional<T>> getLocalOrGlobal(StringRef LocalName) const { - llvm::Optional<StringRef> ValueOr = get(LocalName); + std::optional<StringRef> ValueOr = get(LocalName); bool IsGlobal = false; if (!ValueOr) { IsGlobal = true; @@ -274,9 +274,9 @@ /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template <typename T> - std::enable_if_t<std::is_enum<T>::value, llvm::Optional<T>> + std::enable_if_t<std::is_enum<T>::value, std::optional<T>> get(StringRef LocalName, bool IgnoreCase = false) const { - if (llvm::Optional<int64_t> ValueOr = + if (std::optional<int64_t> ValueOr = getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase)) return static_cast<T>(*ValueOr); return std::nullopt; @@ -314,9 +314,9 @@ /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template <typename T> - std::enable_if_t<std::is_enum<T>::value, llvm::Optional<T>> + std::enable_if_t<std::is_enum<T>::value, std::optional<T>> getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const { - if (llvm::Optional<int64_t> ValueOr = + if (std::optional<int64_t> ValueOr = getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase)) return static_cast<T>(*ValueOr); return std::nullopt; @@ -378,9 +378,9 @@ private: using NameAndValue = std::pair<int64_t, StringRef>; - llvm::Optional<int64_t> getEnumInt(StringRef LocalName, - ArrayRef<NameAndValue> Mapping, - bool CheckGlobal, bool IgnoreCase) const; + std::optional<int64_t> getEnumInt(StringRef LocalName, + ArrayRef<NameAndValue> Mapping, + bool CheckGlobal, bool IgnoreCase) const; template <typename T> std::enable_if_t<std::is_enum<T>::value, std::vector<NameAndValue>> @@ -433,7 +433,7 @@ /// If the corresponding key can't be parsed as a bool, emit a /// diagnostic and return ``std::nullopt``. template <> -llvm::Optional<bool> +std::optional<bool> ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const; /// Read a named option from the ``Context`` and parse it as a bool. @@ -445,7 +445,7 @@ /// If the corresponding key can't be parsed as a bool, emit a /// diagnostic and return \p Default. template <> -llvm::Optional<bool> +std::optional<bool> ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const; /// Stores an option with the check-local name \p LocalName with Index: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -51,7 +51,7 @@ : NamePrefix((CheckName + ".").str()), CheckOptions(CheckOptions), Context(Context) {} -llvm::Optional<StringRef> +std::optional<StringRef> ClangTidyCheck::OptionsView::get(StringRef LocalName) const { if (Context->getOptionsCollector()) Context->getOptionsCollector()->insert((NamePrefix + LocalName).str()); @@ -80,7 +80,7 @@ return IterGlobal; } -llvm::Optional<StringRef> +std::optional<StringRef> ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const { auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context->getOptionsCollector()); @@ -89,10 +89,10 @@ return std::nullopt; } -static Optional<bool> getAsBool(StringRef Value, - const llvm::Twine &LookupName) { +static std::optional<bool> getAsBool(StringRef Value, + const llvm::Twine &LookupName) { - if (llvm::Optional<bool> Parsed = llvm::yaml::parseBool(Value)) + if (std::optional<bool> Parsed = llvm::yaml::parseBool(Value)) return *Parsed; // To maintain backwards compatability, we support parsing numbers as // booleans, even though its not supported in YAML. @@ -103,9 +103,9 @@ } template <> -llvm::Optional<bool> +std::optional<bool> ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const { - if (llvm::Optional<StringRef> ValueOr = get(LocalName)) { + if (std::optional<StringRef> ValueOr = get(LocalName)) { if (auto Result = getAsBool(*ValueOr, NamePrefix + LocalName)) return Result; diagnoseBadBooleanOption(NamePrefix + LocalName, *ValueOr); @@ -114,7 +114,7 @@ } template <> -llvm::Optional<bool> +std::optional<bool> ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const { auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context->getOptionsCollector()); @@ -145,7 +145,7 @@ store(Options, LocalName, Value ? StringRef("true") : StringRef("false")); } -llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt( +std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt( StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal, bool IgnoreCase) const { if (!CheckGlobal && Context->getOptionsCollector())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits