Skip to content

Commit b2d40bb

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents 4489e86 + c5cd1e9 commit b2d40bb

File tree

253 files changed

+9046
-2007
lines changed

Some content is hidden

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

253 files changed

+9046
-2007
lines changed

.ci/generate_test_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def junit_from_xml(xml):
1818

1919
class TestReports(unittest.TestCase):
2020
def test_title_only(self):
21-
self.assertEqual(_generate_report("Foo", []), ("", None))
21+
self.assertEqual(_generate_report("Foo", []), ("", "success"))
2222

2323
def test_no_tests_in_testsuite(self):
2424
self.assertEqual(
@@ -336,7 +336,7 @@ def _generate_report(title, junit_objects, size_limit=1024 * 1024, list_failures
336336
)
337337

338338
if not tests_run:
339-
return ("", style)
339+
return ("", None)
340340

341341
style = "error" if tests_failed else "success"
342342
report = [f"# {title}", ""]

.github/new-issues-labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@
3030

3131
'infra:commit-access-request':
3232
- '/Request Commit Access/'
33+
34+
'false-positive':
35+
- '\bfalse[- ]positive\b'
36+
37+
'false-negative':
38+
- '\bfalse[- ]negative\b'

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ Modified Compiler Flags
436436
to utilize these vector libraries. The behavior for all other vector function
437437
libraries remains unchanged.
438438

439-
- The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
439+
- The ``-Wnontrivial-memcall`` warning has been added to warn about
440440
passing non-trivially-copyable destrination parameter to ``memcpy``,
441441
``memset`` and similar functions for which it is a documented undefined
442-
behavior.
442+
behavior. It is implied by ``-Wnontrivial-memaccess``
443443

444444
Removed Compiler Flags
445445
-------------------------
@@ -473,6 +473,11 @@ Attribute Changes in Clang
473473
- The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It can be used to specify
474474
that a function requires an additional x86-64 thunk, which may be patched at runtime.
475475

476+
- The attribute ``[[clang::no_specializations]]`` has been added to warn
477+
users that a specific template shouldn't be specialized. This is useful for
478+
e.g. standard library type traits, where adding a specialization results in
479+
undefined behaviour.
480+
476481
- ``[[clang::lifetimebound]]`` is now explicitly disallowed on explicit object member functions
477482
where they were previously silently ignored.
478483

clang/docs/UsersManual.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,7 @@ usual build cycle when using sample profilers for optimization:
26602660
26612661
> clang-cl /O2 -gdwarf -gline-tables-only ^
26622662
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
2663-
/fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
2663+
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
26642664
26652665
[OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/
26662666
edge counters. The profile inference algorithm (profi) can be used to infer
@@ -2679,7 +2679,7 @@ usual build cycle when using sample profilers for optimization:
26792679
26802680
> clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf -gline-tables-only ^
26812681
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
2682-
/fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
2682+
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
26832683
26842684
Sample Profile Formats
26852685
""""""""""""""""""""""

clang/include/clang/Basic/Attr.td

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ def NonParmVar : SubsetSubject<Var,
103103
def NonLocalVar : SubsetSubject<Var,
104104
[{!S->hasLocalStorage()}],
105105
"variables with non-local storage">;
106+
def VarTmpl : SubsetSubject<Var, [{S->getDescribedVarTemplate()}],
107+
"variable templates">;
108+
106109
def NonBitField : SubsetSubject<Field,
107110
[{!S->isBitField()}],
108111
"non-bit-field non-static data members">;
@@ -3260,33 +3263,28 @@ def Target : InheritableAttr {
32603263
let Subjects = SubjectList<[Function], ErrorDiag>;
32613264
let Documentation = [TargetDocs];
32623265
let AdditionalMembers = [{
3263-
StringRef getArchitecture() const {
3266+
std::optional<StringRef> getX86Architecture() const {
32643267
StringRef Features = getFeaturesStr();
3265-
if (Features == "default") return {};
3266-
3267-
SmallVector<StringRef, 1> AttrFeatures;
3268-
Features.split(AttrFeatures, ",");
3269-
3270-
for (auto &Feature : AttrFeatures) {
3268+
SmallVector<StringRef, 4> AttrFeatures;
3269+
Features.split(AttrFeatures, ',');
3270+
for (StringRef Feature : AttrFeatures) {
32713271
Feature = Feature.trim();
32723272
if (Feature.starts_with("arch="))
32733273
return Feature.drop_front(sizeof("arch=") - 1);
32743274
}
3275-
return "";
3275+
return std::nullopt;
32763276
}
32773277

32783278
// Gets the list of features as simple string-refs with no +/- or 'no-'.
32793279
// Only adds the items to 'Out' that are additions.
3280-
void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3280+
void getX86AddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3281+
if (isDefaultVersion())
3282+
return;
32813283
StringRef Features = getFeaturesStr();
3282-
if (Features == "default") return;
3283-
3284-
SmallVector<StringRef, 1> AttrFeatures;
3285-
Features.split(AttrFeatures, ",");
3286-
3284+
SmallVector<StringRef, 4> AttrFeatures;
3285+
Features.split(AttrFeatures, ',');
32873286
for (auto &Feature : AttrFeatures) {
32883287
Feature = Feature.trim();
3289-
32903288
if (!Feature.starts_with("no-") && !Feature.starts_with("arch=") &&
32913289
!Feature.starts_with("fpmath=") && !Feature.starts_with("tune="))
32923290
Out.push_back(Feature);
@@ -3304,17 +3302,17 @@ def TargetVersion : InheritableAttr, TargetSpecificAttr<TargetArch<!listconcat(T
33043302
let Documentation = [TargetVersionDocs];
33053303
let AdditionalMembers = [{
33063304
StringRef getName() const { return getNamesStr().trim(); }
3307-
bool isDefaultVersion() const {
3308-
return getName() == "default";
3309-
}
3310-
void getFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3311-
if (isDefaultVersion()) return;
3312-
StringRef Features = getName();
33133305

3314-
SmallVector<StringRef, 8> AttrFeatures;
3315-
Features.split(AttrFeatures, "+");
3306+
bool isDefaultVersion() const { return getName() == "default"; }
33163307

3317-
for (auto &Feature : AttrFeatures) {
3308+
void getFeatures(llvm::SmallVectorImpl<StringRef> &Out,
3309+
char Delim = '+') const {
3310+
if (isDefaultVersion())
3311+
return;
3312+
StringRef Features = getName();
3313+
SmallVector<StringRef, 4> AttrFeatures;
3314+
Features.split(AttrFeatures, Delim);
3315+
for (StringRef Feature : AttrFeatures) {
33183316
Feature = Feature.trim();
33193317
Out.push_back(Feature);
33203318
}
@@ -3331,20 +3329,40 @@ def TargetClones : InheritableAttr {
33313329
StringRef getFeatureStr(unsigned Index) const {
33323330
return *(featuresStrs_begin() + Index);
33333331
}
3332+
33343333
bool isDefaultVersion(unsigned Index) const {
33353334
return getFeatureStr(Index) == "default";
33363335
}
3336+
33373337
void getFeatures(llvm::SmallVectorImpl<StringRef> &Out,
3338-
unsigned Index) const {
3339-
if (isDefaultVersion(Index)) return;
3338+
unsigned Index, char Delim = '+') const {
3339+
if (isDefaultVersion(Index))
3340+
return;
33403341
StringRef Features = getFeatureStr(Index);
3341-
SmallVector<StringRef, 8> AttrFeatures;
3342-
Features.split(AttrFeatures, "+");
3343-
for (auto &Feature : AttrFeatures) {
3342+
SmallVector<StringRef, 4> AttrFeatures;
3343+
Features.split(AttrFeatures, Delim);
3344+
for (StringRef Feature : AttrFeatures) {
33443345
Feature = Feature.trim();
33453346
Out.push_back(Feature);
33463347
}
33473348
}
3349+
3350+
std::optional<StringRef> getX86Architecture(unsigned Index) const {
3351+
StringRef Feature = getFeatureStr(Index);
3352+
if (Feature.starts_with("arch="))
3353+
return Feature.drop_front(sizeof("arch=") - 1);
3354+
return std::nullopt;
3355+
}
3356+
3357+
void getX86Feature(llvm::SmallVectorImpl<StringRef> &Out,
3358+
unsigned Index) const {
3359+
if (isDefaultVersion(Index))
3360+
return;
3361+
if (getX86Architecture(Index))
3362+
return;
3363+
Out.push_back(getFeatureStr(Index));
3364+
}
3365+
33483366
// Given an index into the 'featuresStrs' sequence, compute a unique
33493367
// ID to be used with function name mangling for the associated variant.
33503368
// This mapping is necessary due to a requirement that the mangling ID
@@ -3428,6 +3446,15 @@ def DiagnoseIf : InheritableAttr {
34283446
let Documentation = [DiagnoseIfDocs];
34293447
}
34303448

3449+
def NoSpecializations : InheritableAttr {
3450+
let Spellings = [Clang<"no_specializations", /*AllowInC*/0>];
3451+
let Args = [StringArgument<"Message", 1>];
3452+
let Subjects = SubjectList<[ClassTmpl, FunctionTmpl, VarTmpl]>;
3453+
let Documentation = [NoSpecializationsDocs];
3454+
let MeaningfulToClassTemplateDefinition = 1;
3455+
let TemplateDependent = 1;
3456+
}
3457+
34313458
def ArcWeakrefUnavailable : InheritableAttr {
34323459
let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
34333460
let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,15 @@ Query for this feature with ``__has_attribute(diagnose_if)``.
11551155
}];
11561156
}
11571157

1158+
def NoSpecializationsDocs : Documentation {
1159+
let Category = DocCatDecl;
1160+
let Content = [{
1161+
``[[clang::no_specializations]]`` can be applied to function, class, or variable
1162+
templates which should not be explicitly specialized by users. This is primarily
1163+
used to diagnose user specializations of standard library type traits.
1164+
}];
1165+
}
1166+
11581167
def PassObjectSizeDocs : Documentation {
11591168
let Category = DocCatVariable; // Technically it's a parameter doc, but eh.
11601169
let Heading = "pass_object_size, pass_dynamic_object_size";
@@ -3976,6 +3985,8 @@ The capturing entity ``X`` can be one of the following:
39763985
std::set<std::string_view> s;
39773986
};
39783987

3988+
Note: When applied to a constructor parameter, `[[clang::lifetime_capture_by(this)]]` is just an alias of `[[clang::lifetimebound]]`.
3989+
39793990
- `global`, `unknown`.
39803991

39813992
.. code-block:: c++

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,8 @@ def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
683683
def SizeofPointerMemaccess : DiagGroup<"sizeof-pointer-memaccess">;
684684
def MemsetTransposedArgs : DiagGroup<"memset-transposed-args">;
685685
def DynamicClassMemaccess : DiagGroup<"dynamic-class-memaccess">;
686-
def NonTrivialMemaccess : DiagGroup<"nontrivial-memaccess">;
686+
def NonTrivialMemcall : DiagGroup<"nontrivial-memcall">;
687+
def NonTrivialMemaccess : DiagGroup<"nontrivial-memaccess", [NonTrivialMemcall]>;
687688
def SuspiciousBzero : DiagGroup<"suspicious-bzero">;
688689
def SuspiciousMemaccess : DiagGroup<"suspicious-memaccess",
689690
[SizeofPointerMemaccess, DynamicClassMemaccess,
@@ -1589,4 +1590,3 @@ def ExplicitSpecializationStorageClass : DiagGroup<"explicit-specialization-stor
15891590

15901591
// A warning for options that enable a feature that is not yet complete
15911592
def ExperimentalOption : DiagGroup<"experimental-option">;
1592-

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def warn_cstruct_memaccess : Warning<
798798
def warn_cxxstruct_memaccess : Warning<
799799
"first argument in call to "
800800
"%0 is a pointer to non-trivially copyable type %1">,
801-
InGroup<NonTrivialMemaccess>;
801+
InGroup<NonTrivialMemcall>;
802802
def note_nontrivial_field : Note<
803803
"field is non-trivial to %select{copy|default-initialize}0">;
804804
def err_non_trivial_c_union_in_invalid_context : Error<
@@ -5445,6 +5445,10 @@ def note_dependent_function_template_spec_discard_reason : Note<
54455445
"candidate ignored: %select{not a function template|"
54465446
"not a member of the enclosing %select{class template|"
54475447
"namespace; did you mean to explicitly qualify the specialization?}1}0">;
5448+
def warn_invalid_specialization : Warning<
5449+
"%0 cannot be specialized%select{|: %2}1">,
5450+
DefaultError, InGroup<DiagGroup<"invalid-specialization">>;
5451+
def note_marked_here : Note<"marked %0 here">;
54485452

54495453
// C++ class template specializations and out-of-line definitions
54505454
def err_template_spec_needs_header : Error<

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ namespace clang {
336336
bool isTupleSet() const { return Flags & IsTupleSet; }
337337
bool isReadZA() const { return Flags & IsReadZA; }
338338
bool isWriteZA() const { return Flags & IsWriteZA; }
339+
bool setsFPMR() const { return Flags & SetsFPMR; }
339340
bool isReductionQV() const { return Flags & IsReductionQV; }
340341
uint64_t getBits() const { return Flags; }
341342
bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }

clang/include/clang/Basic/TargetInfo.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,14 +1525,10 @@ class TargetInfo : public TransferrableTargetInfo,
15251525

15261526
// Return the target-specific priority for features/cpus/vendors so
15271527
// that they can be properly sorted for checking.
1528-
virtual unsigned multiVersionSortPriority(StringRef Name) const {
1528+
virtual unsigned getFMVPriority(ArrayRef<StringRef> Features) const {
15291529
return 0;
15301530
}
15311531

1532-
// Return the target-specific cost for feature
1533-
// that taken into account in priority sorting.
1534-
virtual unsigned multiVersionFeatureCost() const { return 0; }
1535-
15361532
// Validate the contents of the __builtin_cpu_is(const char*)
15371533
// argument.
15381534
virtual bool validateCpuIs(StringRef Name) const { return false; }

0 commit comments

Comments
 (0)