addr2line created this revision.
addr2line added a reviewer: MaskRay.
addr2line added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, StephenFan.
Herald added a reviewer: njames93.
Herald added a project: All.
addr2line requested review of this revision.
Herald added a subscriber: cfe-commits.
Just change the optional, NFC.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139919
Files:
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
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>>
@@ -399,7 +399,6 @@
void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
int64_t Value) const;
-
std::string NamePrefix;
const ClangTidyOptions::OptionMap &CheckOptions;
ClangTidyContext *Context;
@@ -433,7 +432,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 +444,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
@@ -455,7 +454,6 @@
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
bool Value) const;
-
} // namespace tidy
} // namespace clang
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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits