Skip to content

Commit 85468c1

Browse files
committed
Merge remote-tracking branch 'origin/main' into 2025q1-machinecopypropagation-noop
2 parents a9ff08e + 7fb71d1 commit 85468c1

File tree

332 files changed

+9470
-3394
lines changed

Some content is hidden

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

332 files changed

+9470
-3394
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ related warnings within the method body.
161161
``__attribute__((model("large")))`` on non-TLS globals in x86-64 compilations.
162162
This forces the global to be considered small or large in regards to the
163163
x86-64 code model, regardless of the code model specified for the compilation.
164-
- Clang now emits a warning ``-Wreserved-init-priority`` instead of a hard error
165-
when ``__attribute__((init_priority(n)))`` is used with values of n in the
164+
- Clang now emits a warning ``-Wreserved-init-priority`` instead of a hard error
165+
when ``__attribute__((init_priority(n)))`` is used with values of n in the
166166
reserved range [0, 100]. The warning will be treated as an error by default.
167167

168168
- There is a new ``format_matches`` attribute to complement the existing
@@ -234,7 +234,8 @@ Improvements to Clang's diagnostics
234234
- Diagnostics on chained comparisons (``a < b < c``) are now an error by default. This can be disabled with
235235
``-Wno-error=parentheses``.
236236
- The ``-Wshift-bool`` warning has been added to warn about shifting a boolean. (#GH28334)
237-
237+
- Fixed diagnostics adding a trailing ``::`` when printing some source code
238+
constructs, like base classes.
238239
- The :doc:`ThreadSafetyAnalysis` now supports ``-Wthread-safety-pointer``,
239240
which enables warning on passing or returning pointers to guarded variables
240241
as function arguments or return value respectively. Note that
@@ -294,16 +295,7 @@ Bug Fixes to C++ Support
294295
direct-list-initialized from an array is corrected to direct-initialization.
295296
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)
296297
- Clang now uses the parameter location for abbreviated function templates in ``extern "C"``. (#GH46386)
297-
298-
Improvements to C++ diagnostics
299-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300-
301-
- Clang now more consistently adds a note pointing to the relevant template
302-
parameter. Some diagnostics are reworded to better take advantage of this.
303-
- Template Template Parameter diagnostics now stop referring to template
304-
parameters as template arguments, in some circumstances, better hiding
305-
from the users template template parameter partial ordering arcana.
306-
298+
- Clang now correctly parses ``if constexpr`` expressions in immediate function context. (#GH123524)
307299

308300
Bug Fixes to AST Handling
309301
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,6 +3522,31 @@ Raw pointers and references to an object which supports CheckedPtr or CheckedRef
35223522
35233523
See `WebKit Guidelines for Safer C++ Programming <https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines>`_ for details.
35243524
3525+
alpha.webkit.NoUnretainedMemberChecker
3526+
""""""""""""""""""""""""""""""""""""""""
3527+
Raw pointers and references to a NS or CF object can't be used as class members or ivars. Only RetainPtr is allowed for CF types regardless of whether ARC is enabled or disabled. Only RetainPtr is allowed for NS types when ARC is disabled.
3528+
3529+
.. code-block:: cpp
3530+
3531+
struct Foo {
3532+
NSObject *ptr; // warn
3533+
// ...
3534+
};
3535+
3536+
See `WebKit Guidelines for Safer C++ Programming <https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines>`_ for details.
3537+
3538+
alpha.webkit.UnretainedLambdaCapturesChecker
3539+
""""""""""""""""""""""""""""""""""""""""""""
3540+
Raw pointers and references to NS or CF types can't be captured in lambdas. Only RetainPtr is allowed for CF types regardless of whether ARC is enabled or disabled, and only RetainPtr is allowed for NS types when ARC is disabled.
3541+
3542+
.. code-block:: cpp
3543+
3544+
void foo(NSObject *a, NSObject *b) {
3545+
[&, a](){ // warn about 'a'
3546+
do_something(b); // warn about 'b'
3547+
};
3548+
};
3549+
35253550
.. _alpha-webkit-UncountedCallArgsChecker:
35263551
35273552
alpha.webkit.UncountedCallArgsChecker

clang/include/clang/AST/NestedNameSpecifier.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ class NestedNameSpecifier : public llvm::FoldingSetNode {
223223
/// `ns::SomeTemplate<int, MyClass>` instead of
224224
/// `ns::SomeTemplate<Container::value_type, T>`.
225225
void print(raw_ostream &OS, const PrintingPolicy &Policy,
226-
bool ResolveTemplateArguments = false) const;
226+
bool ResolveTemplateArguments = false,
227+
bool PrintFinalScopeResOp = true) const;
227228

228229
void Profile(llvm::FoldingSetNodeID &ID) const {
229230
ID.AddPointer(Prefix.getOpaqueValue());

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,5 +1817,9 @@ def ext_hlsl_access_specifiers : ExtWarn<
18171817
InGroup<HLSLExtension>;
18181818
def err_hlsl_unsupported_component : Error<"invalid component '%0' used; expected 'x', 'y', 'z', or 'w'">;
18191819
def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier '%0' for packoffset, expected 'c'">;
1820+
def err_hlsl_virtual_function
1821+
: Error<"virtual functions are unsupported in HLSL">;
1822+
def err_hlsl_virtual_inheritance
1823+
: Error<"virtual inheritance is unsupported in HLSL">;
18201824

18211825
} // end of Parser diagnostics

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,17 @@ def err_using_typename_non_type : Error<
599599
"'typename' keyword used on a non-type">;
600600
def err_using_dependent_value_is_type : Error<
601601
"dependent using declaration resolved to type without 'typename'">;
602-
def err_using_decl_nested_name_specifier_is_not_class : Error<
603-
"using declaration in class refers into '%0', which is not a class">;
602+
def err_using_decl_nested_name_specifier_is_not_class
603+
: Error<"using declaration in class refers into %0, which is not a class">;
604604
def warn_cxx17_compat_using_decl_non_member_enumerator : Warning<
605605
"member using declaration naming non-class '%0' enumerator is "
606606
"incompatible with C++ standards before C++20">, InGroup<CXXPre20Compat>,
607607
DefaultIgnore;
608608
def err_using_decl_nested_name_specifier_is_current_class : Error<
609609
"using declaration refers to its own class">;
610-
def err_using_decl_nested_name_specifier_is_not_base_class : Error<
611-
"using declaration refers into '%0', which is not a base class of %1">;
610+
def err_using_decl_nested_name_specifier_is_not_base_class
611+
: Error<
612+
"using declaration refers into %0, which is not a base class of %1">;
612613
def err_using_decl_constructor_not_in_direct_base : Error<
613614
"%0 is not a direct base of %1, cannot inherit constructors">;
614615
def err_using_decl_can_not_refer_to_class_member : Error<
@@ -1733,8 +1734,8 @@ def err_no_matching_local_friend_suggest : Error<
17331734
"cannot define friend function %0 in a local class definition; did you mean %3?">;
17341735
def err_partial_specialization_friend : Error<
17351736
"partial specialization cannot be declared as a friend">;
1736-
def err_qualified_friend_def : Error<
1737-
"friend function definition cannot be qualified with '%0'">;
1737+
def err_qualified_friend_def
1738+
: Error<"friend function definition cannot be qualified with %0">;
17381739
def err_friend_def_in_local_class : Error<
17391740
"friend function cannot be defined in a local class">;
17401741
def err_friend_specialization_def : Error<
@@ -1743,14 +1744,16 @@ def err_friend_not_first_in_declaration : Error<
17431744
"'friend' must appear first in a non-function declaration">;
17441745
def err_using_decl_friend : Error<
17451746
"cannot befriend target of using declaration">;
1746-
def warn_template_qualified_friend_unsupported : Warning<
1747-
"dependent nested name specifier '%0' for friend class declaration is "
1748-
"not supported; turning off access control for %1">,
1749-
InGroup<UnsupportedFriend>;
1750-
def warn_template_qualified_friend_ignored : Warning<
1751-
"dependent nested name specifier '%0' for friend template declaration is "
1752-
"not supported; ignoring this friend declaration">,
1753-
InGroup<UnsupportedFriend>;
1747+
def warn_template_qualified_friend_unsupported
1748+
: Warning<
1749+
"dependent nested name specifier %0 for friend class declaration is "
1750+
"not supported; turning off access control for %1">,
1751+
InGroup<UnsupportedFriend>;
1752+
def warn_template_qualified_friend_ignored
1753+
: Warning<"dependent nested name specifier %0 for friend template "
1754+
"declaration is "
1755+
"not supported; ignoring this friend declaration">,
1756+
InGroup<UnsupportedFriend>;
17541757
def ext_friend_tag_redecl_outside_namespace : ExtWarn<
17551758
"unqualified friend declaration referring to type outside of the nearest "
17561759
"enclosing namespace is a Microsoft extension; add a nested name specifier">,
@@ -5210,11 +5213,16 @@ def err_template_unnamed_class : Error<
52105213
def err_template_param_list_different_arity : Error<
52115214
"%select{too few|too many}0 template parameters in template "
52125215
"%select{|template parameter }1redeclaration">;
5216+
def note_template_param_list_different_arity : Note<
5217+
"%select{too few|too many}0 template parameters in template template "
5218+
"argument">;
52135219
def note_template_prev_declaration : Note<
52145220
"previous template %select{declaration|template parameter}0 is here">;
52155221
def err_template_param_different_kind : Error<
52165222
"template parameter has a different kind in template "
52175223
"%select{|template parameter }0redeclaration">;
5224+
def note_template_param_different_kind : Note<
5225+
"template parameter has a different kind in template argument">;
52185226

52195227
def err_invalid_decl_specifier_in_nontype_parm : Error<
52205228
"invalid declaration specifier in template non-type parameter">;
@@ -5223,6 +5231,8 @@ def err_template_nontype_parm_different_type : Error<
52235231
"template non-type parameter has a different type %0 in template "
52245232
"%select{|template parameter }1redeclaration">;
52255233

5234+
def note_template_nontype_parm_different_type : Note<
5235+
"template non-type parameter has a different type %0 in template argument">;
52265236
def note_template_nontype_parm_prev_declaration : Note<
52275237
"previous non-type template parameter with type %0 is here">;
52285238
def err_template_nontype_parm_bad_type : Error<
@@ -5313,15 +5323,10 @@ def err_template_missing_args : Error<
53135323
"%select{class template|function template|variable template|alias template|"
53145324
"template template parameter|concept|template}0 %1 requires template "
53155325
"arguments">;
5316-
def err_template_param_missing_arg : Error<
5317-
"missing template argument for template parameter">;
5318-
def err_template_template_param_missing_param : Error<
5319-
"no template parameter in this template template parameter "
5320-
"corresponds to non-defaulted template parameter of argument template">;
5321-
def err_template_too_many_args : Error<
5322-
"too many template arguments for "
5326+
def err_template_arg_list_different_arity : Error<
5327+
"%select{too few|too many}0 template arguments for "
53235328
"%select{class template|function template|variable template|alias template|"
5324-
"template template parameter|concept|template}0 %1">;
5329+
"template template parameter|concept|template}1 %2">;
53255330
def note_template_decl_here : Note<"template is declared here">;
53265331
def note_template_decl_external : Note<
53275332
"template declaration from hidden source: %0">;
@@ -5359,8 +5364,11 @@ def err_template_arg_not_valid_template : Error<
53595364
"template parameter">;
53605365
def note_template_arg_refers_here_func : Note<
53615366
"template argument refers to function template %0, here">;
5367+
def err_template_arg_template_params_mismatch : Error<
5368+
"template template argument has different template parameters than its "
5369+
"corresponding template template parameter">;
53625370
def note_template_arg_template_params_mismatch : Note<
5363-
"template template argument is incompatible with its "
5371+
"template template argument has different template parameters than its "
53645372
"corresponding template template parameter">;
53655373
def err_non_deduced_mismatch : Error<
53665374
"could not match %diff{$ against $|types}0,1">;
@@ -5551,9 +5559,10 @@ def ext_template_spec_extra_headers : ExtWarn<
55515559
def note_explicit_template_spec_does_not_need_header : Note<
55525560
"'template<>' header not required for explicitly-specialized class %0 "
55535561
"declared here">;
5554-
def err_template_qualified_declarator_no_match : Error<
5555-
"nested name specifier '%0' for declaration does not refer into a class, "
5556-
"class template or class template partial specialization">;
5562+
def err_template_qualified_declarator_no_match
5563+
: Error<"nested name specifier %0 for declaration does not refer into a "
5564+
"class, "
5565+
"class template or class template partial specialization">;
55575566
def err_specialize_member_of_template : Error<
55585567
"cannot specialize %select{|(with 'template<>') }0a member of an "
55595568
"unspecialized template">;
@@ -5853,13 +5862,13 @@ def note_typename_member_refers_here : Note<
58535862
"referenced member %0 is declared here">;
58545863
def note_typename_refers_here : Note<
58555864
"referenced %0 is declared here">;
5856-
def err_typename_missing : Error<
5857-
"missing 'typename' prior to dependent type name '%0%1'">;
5858-
def err_typename_missing_template : Error<
5859-
"missing 'typename' prior to dependent type template name '%0%1'">;
5860-
def ext_typename_missing : ExtWarn<
5861-
"missing 'typename' prior to dependent type name '%0%1'">,
5862-
InGroup<DiagGroup<"typename-missing">>;
5865+
def err_typename_missing
5866+
: Error<"missing 'typename' prior to dependent type name %0">;
5867+
def err_typename_missing_template
5868+
: Error<"missing 'typename' prior to dependent type template name %0">;
5869+
def ext_typename_missing
5870+
: ExtWarn<"missing 'typename' prior to dependent type name %0">,
5871+
InGroup<DiagGroup<"typename-missing">>;
58635872
def ext_typename_outside_of_template : ExtWarn<
58645873
"'typename' occurs outside of a template">, InGroup<CXX11>;
58655874
def warn_cxx98_compat_typename_outside_of_template : Warning<
@@ -5873,9 +5882,10 @@ def note_using_value_decl_missing_typename : Note<
58735882
def warn_cxx17_compat_implicit_typename : Warning<"use of implicit 'typename' is "
58745883
"incompatible with C++ standards before C++20">, InGroup<CXX20Compat>,
58755884
DefaultIgnore;
5876-
def ext_implicit_typename : ExtWarn<"missing 'typename' prior to dependent "
5877-
"type name %0%1; implicit 'typename' is a C++20 extension">,
5878-
InGroup<CXX20>;
5885+
def ext_implicit_typename
5886+
: ExtWarn<"missing 'typename' prior to dependent "
5887+
"type name %0; implicit 'typename' is a C++20 extension">,
5888+
InGroup<CXX20>;
58795889

58805890
def err_template_kw_refers_to_non_template : Error<
58815891
"%0%select{| following the 'template' keyword}1 "
@@ -5885,12 +5895,13 @@ def note_template_kw_refers_to_non_template : Note<
58855895
def err_template_kw_refers_to_dependent_non_template : Error<
58865896
"%0%select{| following the 'template' keyword}1 "
58875897
"cannot refer to a dependent template">;
5888-
def err_template_kw_refers_to_type_template : Error<
5889-
"'%0%1' is expected to be a non-type template, but instantiated to a %select{class|type alias}2 template">;
5898+
def err_template_kw_refers_to_type_template
5899+
: Error<"%0 is expected to be a non-type template, but instantiated to a "
5900+
"%select{class|type alias}1 template">;
58905901
def note_referenced_type_template : Note<
58915902
"%select{class|type alias}0 template declared here">;
5892-
def err_template_kw_missing : Error<
5893-
"missing 'template' keyword prior to dependent template name '%0%1'">;
5903+
def err_template_kw_missing
5904+
: Error<"missing 'template' keyword prior to dependent template name %0">;
58945905
def ext_template_outside_of_template : ExtWarn<
58955906
"'template' keyword outside of a template">, InGroup<CXX11>;
58965907
def warn_cxx98_compat_template_outside_of_template : Warning<
@@ -5922,6 +5933,10 @@ def err_template_parameter_pack_non_pack : Error<
59225933
"%select{template type|non-type template|template template}0 parameter"
59235934
"%select{| pack}1 conflicts with previous %select{template type|"
59245935
"non-type template|template template}0 parameter%select{ pack|}1">;
5936+
def note_template_parameter_pack_non_pack : Note<
5937+
"%select{template type|non-type template|template template}0 parameter"
5938+
"%select{| pack}1 does not match %select{template type|non-type template"
5939+
"|template template}0 parameter%select{ pack|}1 in template argument">;
59255940
def note_template_parameter_pack_here : Note<
59265941
"previous %select{template type|non-type template|template template}0 "
59275942
"parameter%select{| pack}1 declared here">;
@@ -7879,8 +7894,8 @@ def err_nogetter_property_incdec : Error<
78797894
"no getter method %1 for %select{increment|decrement}0 of property">;
78807895
def err_no_subobject_property_setting : Error<
78817896
"expression is not assignable">;
7882-
def err_qualified_objc_access : Error<
7883-
"%select{property|instance variable}0 access cannot be qualified with '%1'">;
7897+
def err_qualified_objc_access : Error<"%select{property|instance variable}0 "
7898+
"access cannot be qualified with %1">;
78847899

78857900
def ext_freestanding_complex : Extension<
78867901
"complex numbers are an extension in a freestanding C99 implementation">;
@@ -9830,8 +9845,8 @@ def note_non_usual_function_declared_here : Note<
98309845
// C++ literal operators
98319846
def err_literal_operator_outside_namespace : Error<
98329847
"literal operator %0 must be in a namespace or global scope">;
9833-
def err_literal_operator_id_outside_namespace : Error<
9834-
"non-namespace scope '%0' cannot have a literal operator member">;
9848+
def err_literal_operator_id_outside_namespace
9849+
: Error<"non-namespace scope %0 cannot have a literal operator member">;
98359850
def err_literal_operator_default_argument : Error<
98369851
"literal operator cannot have a default argument">;
98379852
def err_literal_operator_bad_param_count : Error<
@@ -12707,6 +12722,10 @@ def err_hlsl_param_qualifier_mismatch :
1270712722
def err_hlsl_vector_compound_assignment_truncation : Error<
1270812723
"left hand operand of type %0 to compound assignment cannot be truncated "
1270912724
"when used with right hand operand of type %1">;
12725+
def err_hlsl_builtin_scalar_vector_mismatch
12726+
: Error<
12727+
"%select{all|second and third}0 arguments to %1 must be of scalar or "
12728+
"vector type with matching scalar element type%diff{: $ vs $|}2,3">;
1271012729

1271112730
def warn_hlsl_impcast_vector_truncation : Warning<
1271212731
"implicit conversion truncates vector: %0 to %1">, InGroup<Conversion>;

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
515515
// on large _BitInts.
516516
BENIGN_VALUE_LANGOPT(MaxBitIntWidth, 32, 128, "Maximum width of a _BitInt")
517517

518-
COMPATIBLE_LANGOPT(IncrementalExtensions, 1, 0, " True if we want to process statements"
518+
COMPATIBLE_LANGOPT(IncrementalExtensions, 1, 0, "True if we want to process statements "
519519
"on the global scope, ignore EOF token and continue later on (thus "
520520
"avoid tearing the Lexer and etc. down). Controlled by "
521521
"-fincremental-extensions.")

0 commit comments

Comments
 (0)