Skip to content

Commit 44ab1f5

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3016)
2 parents a1b639b + 8f75897 commit 44ab1f5

File tree

400 files changed

+3509
-2442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+3509
-2442
lines changed

clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ using namespace clang::ast_matchers;
1515

1616
namespace clang::tidy::modernize {
1717

18+
// FIXME: Add chrono::treat_as_floating_point_v and chrono::is_clock_v.
19+
// This will require restructuring the code to handle type traits not
20+
// defined directly in std.
1821
static const llvm::StringSet<> ValueTraits = {
1922
"alignment_of",
2023
"conjunction",
@@ -28,6 +31,7 @@ static const llvm::StringSet<> ValueTraits = {
2831
"is_array",
2932
"is_assignable",
3033
"is_base_of",
34+
"is_bind_expression",
3135
"is_bounded_array",
3236
"is_class",
3337
"is_compound",
@@ -40,10 +44,14 @@ static const llvm::StringSet<> ValueTraits = {
4044
"is_destructible",
4145
"is_empty",
4246
"is_enum",
47+
"is_error_code_enum",
48+
"is_error_condition_enum",
49+
"is_execution_policy",
4350
"is_final",
4451
"is_floating_point",
4552
"is_function",
4653
"is_fundamental",
54+
"is_implicit_lifetime",
4755
"is_integral",
4856
"is_invocable",
4957
"is_invocable_r",
@@ -65,14 +73,17 @@ static const llvm::StringSet<> ValueTraits = {
6573
"is_nothrow_invocable_r",
6674
"is_nothrow_move_assignable",
6775
"is_nothrow_move_constructible",
76+
"is_nothrow_relocatable",
6877
"is_nothrow_swappable",
6978
"is_nothrow_swappable_with",
7079
"is_null_pointer",
7180
"is_object",
81+
"is_placeholder",
7282
"is_pointer",
7383
"is_pointer_interconvertible_base_of",
7484
"is_polymorphic",
7585
"is_reference",
86+
"is_replaceable",
7687
"is_rvalue_reference",
7788
"is_same",
7889
"is_scalar",
@@ -91,15 +102,26 @@ static const llvm::StringSet<> ValueTraits = {
91102
"is_trivially_destructible",
92103
"is_trivially_move_assignable",
93104
"is_trivially_move_constructible",
105+
"is_trivially_relocatable",
94106
"is_unbounded_array",
95107
"is_union",
96108
"is_unsigned",
109+
"is_virtual_base_of",
97110
"is_void",
98111
"is_volatile",
99112
"negation",
100113
"rank",
114+
"ratio_equal",
115+
"ratio_greater_equal",
116+
"ratio_greater",
117+
"ratio_less_equal",
118+
"ratio_less",
119+
"ratio_not_equal",
101120
"reference_constructs_from_temporary",
102121
"reference_converts_from_temporary",
122+
"tuple_size",
123+
"uses_allocator",
124+
"variant_size",
103125
};
104126

105127
static const llvm::StringSet<> TypeTraits = {
@@ -130,6 +152,12 @@ static const llvm::StringSet<> TypeTraits = {
130152
"result_of",
131153
"invoke_result",
132154
"type_identity",
155+
"compare_three_way_result",
156+
"common_comparison_category",
157+
"unwrap_ref_decay",
158+
"unwrap_reference",
159+
"tuple_element",
160+
"variant_alternative",
133161
};
134162

135163
static DeclarationName getName(const DependentScopeDeclRefExpr &D) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ Changes in existing checks
281281
excluding variables with ``thread_local`` storage class specifier from being
282282
matched.
283283

284+
- Improved :doc:`modernize-type-traits
285+
<clang-tidy/checks/modernize/type-traits>` check by detecting more type traits.
286+
284287
- Improved :doc:`modernize-use-default-member-init
285288
<clang-tidy/checks/modernize/use-default-member-init>` check by matching
286289
arithmetic operations, ``constexpr`` and ``static`` values, and detecting

clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ Options
3838
#define IS_SIGNED(T) std::is_signed<T>::value
3939

4040
Defaults to `false`.
41+
42+
Limitations
43+
-----------
44+
45+
Does not currently diagnose uses of type traits with nested name
46+
specifiers (e.g. ``std::chrono::is_clock``,
47+
``std::chrono::treat_as_floating_point``).

clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -check-suffixes=',MACRO'
22
// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -- \
33
// RUN: -config='{CheckOptions: {modernize-type-traits.IgnoreMacros: true}}'
4-
// RUN: %check_clang_tidy -std=c++17 %s modernize-type-traits %t -check-suffixes=',CXX17,MACRO,CXX17MACRO'
4+
// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-type-traits %t -check-suffixes=',CXX17,MACRO,CXX17MACRO'
55

66
namespace std {
77
template <typename>
@@ -19,6 +19,11 @@ namespace std {
1919
using type = T;
2020
};
2121

22+
template <typename...>
23+
struct common_type {
24+
using type = int;
25+
};
26+
2227
inline namespace __std_lib_version1 {
2328
template<typename T>
2429
struct add_const {
@@ -66,6 +71,10 @@ using UsingNoTypename = std::enable_if<true>::type;
6671
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use c++14 style type templates
6772
// CHECK-FIXES: using UsingNoTypename = std::enable_if_t<true>;
6873

74+
using VariadicTrait = std::common_type<int, long, bool>::type;
75+
// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use c++14 style type templates
76+
// CHECK-FIXES: using VariadicTrait = std::common_type_t<int, long, bool>;
77+
6978
using UsingSpace = std::enable_if <true>::type;
7079
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use c++14 style type templates
7180
// CHECK-FIXES: using UsingSpace = std::enable_if_t <true>;

clang/include/clang/Basic/arm_sve.td

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ def SVCREATE_3_BF16 : SInst<"svcreate3[_{d}]", "3ddd", "b", MergeNone, "", [IsT
13251325
def SVCREATE_4_BF16 : SInst<"svcreate4[_{d}]", "4dddd", "b", MergeNone, "", [IsTupleCreate, VerifyRuntimeMode]>;
13261326
}
13271327

1328-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
1328+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
13291329
def SVCREATE_2_B : SInst<"svcreate2[_b]", "2dd", "Pc", MergeNone, "", [IsTupleCreate, VerifyRuntimeMode]>;
13301330
def SVCREATE_4_B : SInst<"svcreate4[_b]", "4dddd", "Pc", MergeNone, "", [IsTupleCreate, VerifyRuntimeMode]>;
13311331
}
@@ -1350,18 +1350,17 @@ def SVSET_3_BF16 : SInst<"svset3[_{d}]", "33id", "b", MergeNone, "", [IsTupleSet
13501350
def SVSET_4_BF16 : SInst<"svset4[_{d}]", "44id", "b", MergeNone, "", [IsTupleSet, VerifyRuntimeMode], [ImmCheck<1, ImmCheck0_3>]>;
13511351
}
13521352

1353-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
1353+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
13541354
def SVGET_2_B : SInst<"svget2[_b]", "d2i", "Pc", MergeNone, "", [IsTupleGet, VerifyRuntimeMode], [ImmCheck<1, ImmCheck0_1>]>;
13551355
def SVGET_4_B : SInst<"svget4[_b]", "d4i", "Pc", MergeNone, "", [IsTupleGet, VerifyRuntimeMode], [ImmCheck<1, ImmCheck0_3>]>;
13561356

13571357
def SVSET_2_B : SInst<"svset2[_b]", "22id", "Pc", MergeNone, "", [IsTupleSet, VerifyRuntimeMode], [ImmCheck<1, ImmCheck0_1>]>;
13581358
def SVSET_4_B : SInst<"svset4[_b]", "44id", "Pc", MergeNone, "", [IsTupleSet, VerifyRuntimeMode], [ImmCheck<1, ImmCheck0_3>]>;
1359-
}
13601359

1361-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
13621360
def SVUNDEF_2_B: Inst<"svundef2_b", "2", "Pc", MergeNone, "", [IsUndef, VerifyRuntimeMode], []>;
13631361
def SVUNDEF_4_B: Inst<"svundef4_b", "4", "Pc", MergeNone, "", [IsUndef, VerifyRuntimeMode], []>;
13641362
}
1363+
13651364
////////////////////////////////////////////////////////////////////////////////
13661365
// SVE2 WhileGE/GT
13671366
let SVETargetGuard = "sve2", SMETargetGuard = "sme" in {
@@ -1375,7 +1374,7 @@ def SVWHILEHS_U32 : SInst<"svwhilege_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, "
13751374
def SVWHILEHS_U64 : SInst<"svwhilege_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
13761375
}
13771376

1378-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
1377+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
13791378
def SVWHILEGE_S64_X2 : SInst<"svwhilege_{d}[_{1}]_x2", "2ll", "PcPsPiPl", MergeNone, "aarch64_sve_whilege_x2", [VerifyRuntimeMode]>;
13801379
def SVWHILEGT_S64_X2 : SInst<"svwhilegt_{d}[_{1}]_x2", "2ll", "PcPsPiPl", MergeNone, "aarch64_sve_whilegt_x2", [VerifyRuntimeMode]>;
13811380
def SVWHILEHI_U64_X2 : SInst<"svwhilegt_{d}[_{1}]_x2", "2nn", "PcPsPiPl", MergeNone, "aarch64_sve_whilehi_x2", [VerifyRuntimeMode]>;
@@ -1384,7 +1383,6 @@ let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
13841383
def SVWHILELT_S64_X2 : SInst<"svwhilelt_{d}[_{1}]_x2", "2ll", "PcPsPiPl", MergeNone, "aarch64_sve_whilelt_x2", [VerifyRuntimeMode]>;
13851384
def SVWHILELO_U64_X2 : SInst<"svwhilelt_{d}[_{1}]_x2", "2nn", "PcPsPiPl", MergeNone, "aarch64_sve_whilelo_x2", [VerifyRuntimeMode]>;
13861385
def SVWHILELS_U64_X2 : SInst<"svwhilele_{d}[_{1}]_x2", "2nn", "PcPsPiPl", MergeNone, "aarch64_sve_whilels_x2", [VerifyRuntimeMode]>;
1387-
13881386
}
13891387

13901388
////////////////////////////////////////////////////////////////////////////////
@@ -1999,7 +1997,7 @@ def SVBGRP : SInst<"svbgrp[_{d}]", "ddd", "UcUsUiUl", MergeNone, "aarch64_sv
19991997
def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", MergeNone, "aarch64_sve_bgrp_x", [VerifyRuntimeMode]>;
20001998
}
20011999

2002-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme" in {
2000+
let SVETargetGuard = "sve2p1|sme", SMETargetGuard = "sve2p1|sme" in {
20032001
def SVPSEL_B : SInst<"svpsel_lane_b8", "PPPm", "Pc", MergeNone, "", [VerifyRuntimeMode], []>;
20042002
def SVPSEL_H : SInst<"svpsel_lane_b16", "PPPm", "Ps", MergeNone, "", [VerifyRuntimeMode], []>;
20052003
def SVPSEL_S : SInst<"svpsel_lane_b32", "PPPm", "Pi", MergeNone, "", [VerifyRuntimeMode], []>;
@@ -2093,16 +2091,18 @@ let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
20932091
defm STNT1 : MultiVecStore<"stnt1">;
20942092
}
20952093

2096-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
2094+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
20972095
def SVDOT_X2_S : SInst<"svdot[_{d}_{2}]", "ddhh", "i", MergeNone, "aarch64_sve_sdot_x2", [VerifyRuntimeMode], []>;
20982096
def SVDOT_X2_U : SInst<"svdot[_{d}_{2}]", "ddhh", "Ui", MergeNone, "aarch64_sve_udot_x2", [VerifyRuntimeMode], []>;
20992097
def SVDOT_X2_F : SInst<"svdot[_{d}_{2}]", "ddhh", "f", MergeNone, "aarch64_sve_fdot_x2", [VerifyRuntimeMode], []>;
21002098
def SVDOT_LANE_X2_S : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "i", MergeNone, "aarch64_sve_sdot_lane_x2", [VerifyRuntimeMode], [ImmCheck<3, ImmCheck0_3>]>;
21012099
def SVDOT_LANE_X2_U : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "Ui", MergeNone, "aarch64_sve_udot_lane_x2", [VerifyRuntimeMode], [ImmCheck<3, ImmCheck0_3>]>;
21022100
def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "f", MergeNone, "aarch64_sve_fdot_lane_x2", [VerifyRuntimeMode], [ImmCheck<3, ImmCheck0_3>]>;
2101+
2102+
def SVFCLAMP : SInst<"svclamp[_{d}]", "dddd", "hfd", MergeNone, "aarch64_sve_fclamp", [VerifyRuntimeMode], []>;
21032103
}
21042104

2105-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme" in {
2105+
let SVETargetGuard = "sve2p1|sme", SMETargetGuard = "sve2p1|sme" in {
21062106
def SVSCLAMP : SInst<"svclamp[_{d}]", "dddd", "csil", MergeNone, "aarch64_sve_sclamp", [VerifyRuntimeMode], []>;
21072107
def SVUCLAMP : SInst<"svclamp[_{d}]", "dddd", "UcUsUiUl", MergeNone, "aarch64_sve_uclamp", [VerifyRuntimeMode], []>;
21082108

@@ -2114,7 +2114,6 @@ let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
21142114

21152115
def SVPFALSE_COUNT_ALIAS : SInst<"svpfalse_c", "}v", "", MergeNone, "", [IsOverloadNone, VerifyRuntimeMode]>;
21162116

2117-
def SVFCLAMP : SInst<"svclamp[_{d}]", "dddd", "hfd", MergeNone, "aarch64_sve_fclamp", [VerifyRuntimeMode], []>;
21182117
def SVCNTP_COUNT : SInst<"svcntp_{d}", "n}i", "QcQsQiQl", MergeNone, "aarch64_sve_cntp_{d}", [IsOverloadNone, VerifyRuntimeMode], [ImmCheck<1, ImmCheck2_4_Mul2>]>;
21192118
}
21202119

@@ -2271,7 +2270,9 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2,faminmax" in {
22712270
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
22722271
def REINTERPRET_SVBOOL_TO_SVCOUNT : Inst<"svreinterpret[_c]", "}P", "Pc", MergeNone, "", [VerifyRuntimeMode], []>;
22732272
def REINTERPRET_SVCOUNT_TO_SVBOOL : Inst<"svreinterpret[_b]", "P}", "Pc", MergeNone, "", [VerifyRuntimeMode], []>;
2273+
}
22742274

2275+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
22752276
// SQRSHRN / UQRSHRN
22762277
def SVQRSHRN_X2 : SInst<"svqrshrn[_n]_{0}[_{d}_x2]", "h2i", "i", MergeNone, "aarch64_sve_sqrshrn_x2", [VerifyRuntimeMode], [ImmCheck<1, ImmCheck1_16>]>;
22772278
def SVUQRSHRN_X2 : SInst<"svqrshrn[_n]_{0}[_{d}_x2]", "e2i", "Ui", MergeNone, "aarch64_sve_uqrshrn_x2", [VerifyRuntimeMode], [ImmCheck<1, ImmCheck1_16>]>;
@@ -2383,7 +2384,7 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2" in {
23832384
//
23842385
// Multi-vector saturating extract narrow and interleave
23852386
//
2386-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
2387+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
23872388
def SVQCVTN_S16_S32_X2 : SInst<"svqcvtn_s16[_{d}_x2]", "h2.d", "i", MergeNone, "aarch64_sve_sqcvtn_x2", [VerifyRuntimeMode], []>;
23882389
def SVQCVTN_U16_U32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "Ui", MergeNone, "aarch64_sve_uqcvtn_x2", [VerifyRuntimeMode], []>;
23892390
def SVQCVTN_U16_S32_X2 : SInst<"svqcvtn_u16[_{d}_x2]", "e2.d", "i", MergeNone, "aarch64_sve_sqcvtun_x2", [VerifyRuntimeMode], []>;
@@ -2448,7 +2449,7 @@ let SVETargetGuard = InvalidMode, SMETargetGuard = "sme2,fp8" in {
24482449
def SVFCVTN_X4 : Inst<"svcvtn_mf8[_{d}_x4]", "~4>", "f", MergeNone, "aarch64_sve_fp8_cvtn_x4", [IsOverloadNone, IsStreaming], []>;
24492450
}
24502451

2451-
let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in {
2452+
let SVETargetGuard = "sve2p1|sme2", SMETargetGuard = "sve2p1|sme2" in {
24522453
// == BFloat16 multiply-subtract ==
24532454
def SVBFMLSLB : SInst<"svbfmlslb[_{d}]", "dd$$", "f", MergeNone, "aarch64_sve_bfmlslb", [IsOverloadNone, VerifyRuntimeMode], []>;
24542455
def SVBFMLSLT : SInst<"svbfmlslt[_{d}]", "dd$$", "f", MergeNone, "aarch64_sve_bfmlslt", [IsOverloadNone, VerifyRuntimeMode], []>;

0 commit comments

Comments
 (0)