Skip to content

Commit 68f845a

Browse files
committed
Merge from 'main' to 'sycl-web' (60 commits)
CONFLICT (content): Merge conflict in clang/lib/AST/RecordLayoutBuilder.cpp CONFLICT (content): Merge conflict in clang/lib/Basic/Targets/SPIR.h
2 parents 31193bc + beea2a9 commit 68f845a

File tree

513 files changed

+10004
-6544
lines changed

Some content is hidden

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

513 files changed

+10004
-6544
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ namespace clang::tidy {
5555

5656
namespace {
5757
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
58+
#define ANALYZER_CHECK_NAME_PREFIX "clang-analyzer-"
5859
static constexpr llvm::StringLiteral AnalyzerCheckNamePrefix =
59-
"clang-analyzer-";
60+
ANALYZER_CHECK_NAME_PREFIX;
6061

6162
class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
6263
public:
@@ -669,18 +670,19 @@ getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers) {
669670
Buffer.append(AnalyzerCheck);
670671
Result.Checks.insert(Buffer);
671672
}
672-
for (std::string OptionName : {
673+
674+
static constexpr llvm::StringLiteral OptionNames[] = {
673675
#define GET_CHECKER_OPTIONS
674676
#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT, \
675677
RELEASE, HIDDEN) \
676-
Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
678+
ANALYZER_CHECK_NAME_PREFIX CHECKER ":" OPTION_NAME,
677679

678680
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
679681
#undef CHECKER_OPTION
680682
#undef GET_CHECKER_OPTIONS
681-
}) {
682-
Result.Options.insert(OptionName);
683-
}
683+
};
684+
685+
Result.Options.insert_range(OptionNames);
684686
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
685687

686688
Context.setOptionsCollector(&Result.Options);

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/Attr.td

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,22 @@ def TargetHasDLLImportExport : TargetSpec {
503503
def TargetItaniumCXXABI : TargetSpec {
504504
let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
505505
}
506+
506507
def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
507508
let CustomCode = [{ Target.getCXXABI().isMicrosoft() }];
508509
}
510+
511+
// The target follows Microsoft record layout. Usually this happens in two
512+
// cases: 1. the target itself has Microsoft C++ ABI, e.g. x86_64 in MSVC
513+
// environment on Windows 2. an offloading target e.g. amdgcn or nvptx with
514+
// a host target in MSVC environment on Windows.
515+
def TargetMicrosoftRecordLayout : TargetArch<["x86", "x86_64", "arm", "thumb",
516+
"aarch64", "amdgcn", "nvptx",
517+
"nvptx64", "spirv", "spirv32",
518+
"spirv64"]> {
519+
let CustomCode = [{ Target.hasMicrosoftRecordLayout() }];
520+
}
521+
509522
def TargetELF : TargetSpec {
510523
let ObjectFormats = ["ELF"];
511524
}
@@ -2466,7 +2479,7 @@ def Destructor : InheritableAttr {
24662479
let Documentation = [CtorDtorDocs];
24672480
}
24682481

2469-
def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2482+
def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftRecordLayout> {
24702483
let Spellings = [Declspec<"empty_bases">];
24712484
let Subjects = SubjectList<[CXXRecord]>;
24722485
let Documentation = [EmptyBasesDocs];
@@ -2698,7 +2711,7 @@ def Restrict : InheritableAttr {
26982711
let Documentation = [RestrictDocs];
26992712
}
27002713

2701-
def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
2714+
def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftRecordLayout> {
27022715
let Spellings = [Declspec<"layout_version">];
27032716
let Args = [UnsignedArgument<"Version">];
27042717
let Subjects = SubjectList<[CXXRecord]>;
@@ -3198,7 +3211,7 @@ def NoUniqueAddress : InheritableAttr {
31983211
let Spellings = [CXX11<"", "no_unique_address", 201803>, CXX11<"msvc", "no_unique_address", 201803>];
31993212
let TargetSpecificSpellings = [
32003213
TargetSpecificSpelling<TargetItaniumCXXABI, [CXX11<"", "no_unique_address", 201803>]>,
3201-
TargetSpecificSpelling<TargetMicrosoftCXXABI, [CXX11<"msvc", "no_unique_address", 201803>]>,
3214+
TargetSpecificSpelling<TargetMicrosoftRecordLayout, [CXX11<"msvc", "no_unique_address", 201803>]>,
32023215
];
32033216
let Documentation = [NoUniqueAddressDocs];
32043217
}

clang/include/clang/Basic/BuiltinsSPIRVCL.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ include "clang/Basic/BuiltinsSPIRVBase.td"
1010

1111
def generic_cast_to_ptr_explicit
1212
: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>;
13+
def global_size : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
14+
def global_offset : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
15+
def subgroup_max_size : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;

clang/include/clang/Basic/BuiltinsSPIRVCommon.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
include "clang/Basic/BuiltinsSPIRVBase.td"
1010

11+
def num_workgroups : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
12+
def workgroup_size : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
13+
def workgroup_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
14+
def local_invocation_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
15+
def global_invocation_id : SPIRVBuiltin<"size_t(int)", [NoThrow, Const]>;
16+
def subgroup_size : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
17+
def num_subgroups : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
18+
def subgroup_id : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
19+
def subgroup_local_invocation_id : SPIRVBuiltin<"uint32_t()", [NoThrow, Const]>;
20+
1121
def distance : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
1222
def length : SPIRVBuiltin<"void(...)", [NoThrow, Const]>;
1323
def smoothstep : SPIRVBuiltin<"void(...)", [NoThrow, Const, CustomTypeChecking]>;

clang/include/clang/Basic/TargetInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class TargetInfo : public TransferrableTargetInfo,
289289

290290
std::optional<llvm::Triple> DarwinTargetVariantTriple;
291291

292+
bool HasMicrosoftRecordLayout = false;
293+
292294
// TargetInfo Constructor. Default initializes all fields.
293295
TargetInfo(const llvm::Triple &T);
294296

@@ -1331,7 +1333,8 @@ class TargetInfo : public TransferrableTargetInfo,
13311333
/// Apply changes to the target information with respect to certain
13321334
/// language options which change the target configuration and adjust
13331335
/// the language based on the target options where applicable.
1334-
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
1336+
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
1337+
const TargetInfo *Aux);
13351338

13361339
/// Initialize the map with the default set of target features for the
13371340
/// CPU this should include all legal feature strings on the target.
@@ -1846,6 +1849,8 @@ class TargetInfo : public TransferrableTargetInfo,
18461849

18471850
virtual void setAuxTarget(const TargetInfo *Aux) {}
18481851

1852+
bool hasMicrosoftRecordLayout() const { return HasMicrosoftRecordLayout; }
1853+
18491854
/// Whether target allows debuginfo types for decl only variables/functions.
18501855
virtual bool allowDebugInfoForExternalRef() const { return false; }
18511856

0 commit comments

Comments
 (0)