[clang-tools-extra] 7142f73 - [clang-tidy][NFC] Fix modernize-type-traits findings
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 01:53:55 PDT 2023
Author: Piotr Zegar
Date: 2023-08-27T08:52:11Z
New Revision: 7142f731233a84255ca58327b857cf211a910837
URL: https://github.com/llvm/llvm-project/commit/7142f731233a84255ca58327b857cf211a910837
DIFF: https://github.com/llvm/llvm-project/commit/7142f731233a84255ca58327b857cf211a910837.diff
LOG: [clang-tidy][NFC] Fix modernize-type-traits findings
Fix issues found by clang-tidy in clang-tidy source directory.
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 17e9df96c39bec..39b9f9fa865b76 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -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{};
@@ -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);
}
@@ -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;
@@ -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);
}
@@ -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))
@@ -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);
}
@@ -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))
@@ -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);
@@ -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);
@@ -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 =
@@ -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();
diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index d8c7c52ba89ace..e2c2dad6cf323e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -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 {
More information about the cfe-commits
mailing list