Skip to content

Commit

Permalink
[clang-tidy][NFC] Fix modernize-type-traits findings
Browse files Browse the repository at this point in the history
Fix issues found by clang-tidy in clang-tidy source directory.
  • Loading branch information
PiotrZSL committed Aug 27, 2023
1 parent 24a7587 commit 7142f73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions clang-tools-extra/clang-tidy/ClangTidyCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// 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, std::optional<T>>
std::enable_if_t<std::is_integral_v<T>, std::optional<T>>
get(StringRef LocalName) const {
if (std::optional<StringRef> Value = get(LocalName)) {
T Result{};
Expand All @@ -211,8 +211,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// If the corresponding key can't be parsed as a ``T``, emit a
/// diagnostic and return \p Default.
template <typename T>
std::enable_if_t<std::is_integral<T>::value, T> get(StringRef LocalName,
T Default) const {
std::enable_if_t<std::is_integral_v<T>, T> get(StringRef LocalName,
T Default) const {
return get<T>(LocalName).value_or(Default);
}

Expand All @@ -227,7 +227,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// 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, std::optional<T>>
std::enable_if_t<std::is_integral_v<T>, std::optional<T>>
getLocalOrGlobal(StringRef LocalName) const {
std::optional<StringRef> ValueOr = get(LocalName);
bool IsGlobal = false;
Expand Down Expand Up @@ -256,7 +256,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// If the corresponding key can't be parsed as a ``T``, emit a
/// diagnostic and return \p Default.
template <typename T>
std::enable_if_t<std::is_integral<T>::value, T>
std::enable_if_t<std::is_integral_v<T>, T>
getLocalOrGlobal(StringRef LocalName, T Default) const {
return getLocalOrGlobal<T>(LocalName).value_or(Default);
}
Expand All @@ -274,7 +274,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// \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, std::optional<T>>
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
get(StringRef LocalName, bool IgnoreCase = false) const {
if (std::optional<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
Expand All @@ -295,8 +295,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// \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, T>
get(StringRef LocalName, T Default, bool IgnoreCase = false) const {
std::enable_if_t<std::is_enum_v<T>, T> get(StringRef LocalName, T Default,
bool IgnoreCase = false) const {
return get<T>(LocalName, IgnoreCase).value_or(Default);
}

Expand All @@ -314,7 +314,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// \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, std::optional<T>>
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
if (std::optional<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
Expand All @@ -336,7 +336,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// \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, T>
std::enable_if_t<std::is_enum_v<T>, T>
getLocalOrGlobal(StringRef LocalName, T Default,
bool IgnoreCase = false) const {
return getLocalOrGlobal<T>(LocalName, IgnoreCase).value_or(Default);
Expand All @@ -350,7 +350,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// Stores an option with the check-local name \p LocalName with
/// integer value \p Value to \p Options.
template <typename T>
std::enable_if_t<std::is_integral<T>::value>
std::enable_if_t<std::is_integral_v<T>>
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
T Value) const {
storeInt(Options, LocalName, Value);
Expand All @@ -362,7 +362,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
/// \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>
std::enable_if_t<std::is_enum_v<T>>
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
T Value) const {
ArrayRef<std::pair<T, StringRef>> Mapping =
Expand All @@ -383,7 +383,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
bool CheckGlobal, bool IgnoreCase) const;

template <typename T>
std::enable_if_t<std::is_enum<T>::value, std::vector<NameAndValue>>
std::enable_if_t<std::is_enum_v<T>, std::vector<NameAndValue>>
typeEraseMapping() const {
ArrayRef<std::pair<T, StringRef>> Mapping =
OptionEnumMapping<T>::getEnumMapping();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ struct Mix {
};

// NOLINTNEXTLINE(misc-redundant-expression): Seems to be a bogus warning.
static_assert(std::is_trivially_copyable<Mix>::value &&
std::is_trivially_move_constructible<Mix>::value &&
std::is_trivially_move_assignable<Mix>::value,
static_assert(std::is_trivially_copyable_v<Mix> &&
std::is_trivially_move_constructible_v<Mix> &&
std::is_trivially_move_assignable_v<Mix>,
"Keep frequently used data simple!");

struct MixableParameterRange {
Expand Down

0 comments on commit 7142f73

Please sign in to comment.