Skip to content

Commit 495cf8a

Browse files
committed
Merge branch 'main' into fix-clang-linker-wrapper-remarks-yaml
2 parents 670d2ab + 752e31c commit 495cf8a

File tree

1,179 files changed

+45957
-42823
lines changed

Some content is hidden

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

1,179 files changed

+45957
-42823
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
/clang/www/cxx_dr_status.html @Endilll
3232
/clang/www/make_cxx_dr_status @Endilll
3333

34-
/clang/include/clang/CIR @lanza @bcardosolopes
35-
/clang/lib/CIR @lanza @bcardosolopes
36-
/clang/tools/cir-* @lanza @bcardosolopes
34+
/clang/include/clang/CIR @lanza @bcardosolopes @xlauko @andykaylor
35+
/clang/lib/CIR @lanza @bcardosolopes @xlauko @andykaylor
36+
/clang/tools/cir-* @lanza @bcardosolopes @xlauko @andykaylor
3737

3838
/lldb/ @JDevlieghere
3939

.github/workflows/premerge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
if: >-
7777
github.repository_owner == 'llvm' &&
7878
(github.event_name != 'pull_request' || github.event.action != 'closed')
79-
runs-on: llvm-premerge-windows-runners
79+
runs-on: llvm-premerge-windows-2022-runners
8080
defaults:
8181
run:
8282
shell: bash

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
219219

220220
IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
221221
PCHContainerOperations PCHOperations;
222+
CodeGenOptions CodeGenOpts;
222223
ASTReader Reader(PP, *ModCache, /*ASTContext=*/nullptr,
223-
PCHOperations.getRawReader(), {});
224+
PCHOperations.getRawReader(), CodeGenOpts, {});
224225

225226
// We don't need any listener here. By default it will use a validator
226227
// listener.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ Improvements to clang-doc
8888
Improvements to clang-query
8989
---------------------------
9090

91+
- Matcher queries interpreted by clang-query are now support trailing comma (,)
92+
in matcher arguments. Note that C++ still doesn't allow this in function
93+
arguments. So when porting a query to C++, remove all instances of trailing
94+
comma (otherwise C++ compiler will just complain about "expected expression").
95+
9196
Improvements to include-cleaner
9297
-------------------------------
9398
- Deprecated the ``-insert`` and ``-remove`` command line options, and added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
void foo(void) {}
2+
// CHECK-OK: trailing-comma.c:1:1: note: "root" binds here
3+
// CHECK-ERR-COMMA: Invalid token <,> found when looking for a value.
4+
5+
// RUN: clang-query -c "match \
6+
// RUN: functionDecl( \
7+
// RUN: hasName( \
8+
// RUN: \"foo\", \
9+
// RUN: ), \
10+
// RUN: ) \
11+
// RUN: " %s | FileCheck --check-prefix=CHECK-OK %s
12+
13+
// Same with \n tokens
14+
// RUN: echo "match functionDecl( hasName( \"foo\" , ) , )" | sed "s/ /\n/g" >%t
15+
// RUN: clang-query -f %t %s | FileCheck --check-prefix=CHECK-OK %s
16+
17+
// RUN: not clang-query -c "match functionDecl(hasName(\"foo\"),,)" %s \
18+
// RUN: | FileCheck --check-prefix=CHECK-ERR-COMMA %s
19+
20+
// RUN: not clang-query -c "match functionDecl(,)" %s \
21+
// RUN: | FileCheck --check-prefix=CHECK-ERR-COMMA %s
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
=========================
2+
C++ Type Aware Allocators
3+
=========================
4+
5+
.. contents::
6+
:local:
7+
8+
Introduction
9+
============
10+
11+
Clang includes an implementation of P2719 "Type-aware allocation and deallocation
12+
functions".
13+
14+
This is a feature that extends the semantics of `new`, `new[]`, `delete` and
15+
`delete[]` operators to expose the type being allocated to the operator. This
16+
can be used to customize allocation of types without needing to modify the
17+
type declaration, or via template definitions fully generic type aware
18+
allocators.
19+
20+
P2719 introduces a type-identity tag as valid parameter type for all allocation
21+
operators. This tag is a default initialized value of type `std::type_identity<T>`
22+
where T is the type being allocated or deallocated. Unlike the other placement
23+
arguments this tag is passed as the first parameter to the operator.
24+
25+
The most basic use case is as follows
26+
27+
.. code-block:: c++
28+
29+
#include <new>
30+
#include <type_traits>
31+
32+
struct S {
33+
// ...
34+
};
35+
36+
void *operator new(std::type_identity<S>, size_t, std::align_val_t);
37+
void operator delete(std::type_identity<S>, void *, size_t, std::align_val_t);
38+
39+
void f() {
40+
S *s = new S; // calls ::operator new(std::type_identity<S>(), sizeof(S), alignof(S))
41+
delete s; // calls ::operator delete(std::type_identity<S>(), s, sizeof(S), alignof(S))
42+
}
43+
44+
While this functionality alone is powerful and useful, the true power comes
45+
by using templates. In addition to adding the type-identity tag, P2719 allows
46+
the tag parameter to be a dependent specialization of `std::type_identity`,
47+
updates the overload resolution rules to support full template deduction and
48+
constraint semantics, and updates the definition of usual deallocation functions
49+
to include `operator delete` definitions that are templatized on the
50+
type-identity tag.
51+
52+
This allows arbitrarily constrained definitions of the operators that resolve
53+
as would be expected for any other template function resolution, e.g (only
54+
showing `operator new` for brevity)
55+
56+
.. code-block:: c++
57+
58+
template <typename T, unsigned Size> struct Array {
59+
T buffer[Size];
60+
};
61+
62+
// Starting with a concrete type
63+
void *operator new(std::type_identity<Array<int, 5>>, size_t, std::align_val_t);
64+
65+
// Only care about five element arrays
66+
template <typename T>
67+
void *operator new(std::type_identity<Array<T, 5>>, size_t, std::align_val_t);
68+
69+
// An array of N floats
70+
template <unsigned N>
71+
void *operator new(std::type_identity<Array<float, N>>, size_t, std::align_val_t);
72+
73+
// Any array
74+
template <typename T, unsigned N>
75+
void *operator new(std::type_identity<Array<T, N>>, size_t, std::align_val_t);
76+
77+
// A handy concept
78+
template <typename T> concept Polymorphic = std::is_polymorphic_v<T>;
79+
80+
// Only applies is T is Polymorphic
81+
template <Polymorphic T, unsigned N>
82+
void *operator new(std::type_identity<Array<T, N>>, size_t, std::align_val_t);
83+
84+
// Any even length array
85+
template <typename T, unsigned N>
86+
void *operator new(std::type_identity<Array<T, N>>, size_t, std::align_val_t)
87+
requires(N%2 == 0);
88+
89+
Operator selection then proceeds according to the usual rules for choosing
90+
the best/most constrained match.
91+
92+
Any declaration of a type aware operator new or operator delete must include a
93+
matching complimentary operator defined in the same scope.
94+
95+
Notes
96+
=====
97+
98+
Unconstrained Global Operators
99+
------------------------------
100+
101+
Declaring an unconstrained type aware global operator `new` or `delete` (or
102+
`[]` variants) creates numerous hazards, similar to, but different from, those
103+
created by attempting to replace the non-type aware global operators. For that
104+
reason unconstrained operators are strongly discouraged.
105+
106+
Mismatching Constraints
107+
-----------------------
108+
109+
When declaring global type aware operators you should ensure the constraints
110+
applied to new and delete match exactly, and declare them together. This
111+
limits the risk of having mismatching operators selected due to differing
112+
constraints resulting in changes to prioritization when determining the most
113+
viable candidate.
114+
115+
Declarations Across Libraries
116+
-----------------------------
117+
118+
Declaring a typed allocator for a type in a separate TU or library creates
119+
similar hazards as different libraries and TUs may see (or select) different
120+
definitions.
121+
122+
Under this model something like this would be risky
123+
124+
.. code-block:: c++
125+
126+
template<typename T>
127+
void *operator new(std::type_identity<std::vector<T>>, size_t, std::align_val_t);
128+
129+
However this hazard is not present simply due to the use of the a type from
130+
another library:
131+
132+
.. code-block:: c++
133+
134+
template<typename T>
135+
struct MyType {
136+
T thing;
137+
};
138+
template<typename T>
139+
void *operator new(std::type_identity<MyType<std::vector<T>>>, size_t, std::align_val_t);
140+
141+
Here we see `std::vector` being used, but that is not the actual type being
142+
allocated.
143+
144+
Implicit and Placement Parameters
145+
---------------------------------
146+
147+
Type aware allocators are always passed both the implicit alignment and size
148+
parameters in all cases. Explicit placement parameters are supported after the
149+
mandatory implicit parameters.
150+
151+
Publication
152+
===========
153+
154+
`Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_.
155+
Louis Dionne, Oliver Hunt.

clang/docs/LanguageExtensions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Clang Language Extensions
1515
AutomaticReferenceCounting
1616
PointerAuthentication
1717
MatrixTypes
18+
CXXTypeAwareAllocators
1819

1920
Introduction
2021
============
@@ -1540,6 +1541,13 @@ Use ``__has_feature(cxx_variable_templates)`` or
15401541
``__has_extension(cxx_variable_templates)`` to determine if support for
15411542
templated variable declarations is enabled.
15421543

1544+
C++ type aware allocators
1545+
^^^^^^^^^^^^^^^^^^^^^^^^^
1546+
1547+
Use ``__has_extension(cxx_type_aware_allocators)`` to determine the existence of
1548+
support for the future C++2d type aware allocator feature. For full details see
1549+
:doc:`C++ Type Aware Allocators <CXXTypeAwareAllocators>` for additional details.
1550+
15431551
C11
15441552
---
15451553

clang/docs/ReleaseNotes.rst

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Potentially Breaking Changes
3636

3737
- The Objective-C ARC migrator (ARCMigrate) has been removed.
3838
- Fix missing diagnostics for uses of declarations when performing typename access,
39-
such as when performing member access on a '[[deprecated]]' type alias.
39+
such as when performing member access on a ``[[deprecated]]`` type alias.
4040
(#GH58547)
4141
- For ARM targets when compiling assembly files, the features included in the selected CPU
4242
or Architecture's FPU are included. If you wish not to use a specific feature,
@@ -133,8 +133,6 @@ C++2c Feature Support
133133

134134
- Implemented `P0963R3 Structured binding declaration as a condition <https://wg21.link/P0963R3>`_.
135135

136-
- Implemented `P2719R4 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_.
137-
138136
- Implemented `P3618R0 Allow attaching main to the global module <https://wg21.link/P3618>`_.
139137

140138
C++23 Feature Support
@@ -676,7 +674,7 @@ Improvements to Clang's diagnostics
676674
#GH142457, #GH139913, #GH138850, #GH137867, #GH137860, #GH107840, #GH93308,
677675
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
678676
#GH36703, #GH32903, #GH23312, #GH69874.
679-
677+
680678
- Clang no longer emits a spurious -Wdangling-gsl warning in C++23 when
681679
iterating over an element of a temporary container in a range-based
682680
for loop.(#GH109793, #GH145164)
@@ -707,6 +705,11 @@ Improvements to Clang's diagnostics
707705
- Improve the diagnostics for placement new expression when const-qualified
708706
object was passed as the storage argument. (#GH143708)
709707

708+
- Clang now does not issue a warning about returning from a function declared with
709+
the ``[[noreturn]]`` attribute when the function body is ended with a call via
710+
pointer, provided it can be proven that the pointer only points to
711+
``[[noreturn]]`` functions.
712+
710713
Improvements to Clang's time-trace
711714
----------------------------------
712715

@@ -797,6 +800,8 @@ Bug Fixes in This Version
797800
declaration statements. Clang now emits a warning for these patterns. (#GH141659)
798801
- Fixed false positives for redeclaration errors of using enum in
799802
nested scopes. (#GH147495)
803+
- Fixed a failed assertion with an operator call expression which comes from a
804+
macro expansion when performing analysis for nullability attributes. (#GH138371)
800805

801806
Bug Fixes to Compiler Builtins
802807
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -950,6 +955,7 @@ Bug Fixes to C++ Support
950955
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
951956
- Correctly handles calling an explicit object member function template overload set
952957
through its address (``(&Foo::bar<baz>)()``).
958+
- Fix a crash when using an explicit object parameter in a non-member function. (#GH113185)
953959
- Fix a crash when forming an invalid call to an operator with an explicit object member. (#GH147121)
954960
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
955961
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
@@ -963,6 +969,8 @@ Bug Fixes to C++ Support
963969
- Fix a crash with NTTP when instantiating local class.
964970
- Fixed a crash involving list-initialization of an empty class with a
965971
non-empty initializer list. (#GH147949)
972+
- Fixed constant evaluation of equality comparisons of constexpr-unknown references. (#GH147663)
973+
- Diagnose binding a reference to ``*nullptr`` during constant evaluation. (#GH48665)
966974

967975
Bug Fixes to AST Handling
968976
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1024,15 +1032,29 @@ Arm and AArch64 Support
10241032
`as specified here <https://github.com/ARM-software/acle/blob/main/main/acle.md#modal-8-bit-floating-point-extensions>`_
10251033
is now available.
10261034
- Support has been added for the following processors (command-line identifiers in parentheses):
1035+
10271036
- Arm Cortex-A320 (``cortex-a320``)
1037+
10281038
- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Architecture.
10291039
- The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with
10301040
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
10311041
also now printed when the ``--print-supported-extensions`` option is used.
10321042
- When a feature that depends on NEON (``simd``) is used, NEON is now automatically enabled.
10331043
- When NEON is disabled (``+nosimd``), all features that depend on NEON will now be disabled.
10341044

1035-
- Support for __ptrauth type qualifier has been added.
1045+
- Pointer authentication
1046+
1047+
- Support for __ptrauth type qualifier has been added.
1048+
- Objective-C adoption of pointer authentication
1049+
1050+
- ``isa`` and ``super`` pointers are protected with address diversity and separate
1051+
usage specific discriminators.
1052+
- methodlist pointers and content are protected with address diversity and methodlist
1053+
pointers have a usage specific discriminator.
1054+
- ``class_ro_t`` pointers are protected with address diversity and usage specific
1055+
discriminators.
1056+
- ``SEL`` typed ivars are protected with address diversity and usage specific
1057+
discriminators.
10361058

10371059
- For AArch64, added support for generating executable-only code sections by using the
10381060
``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688)
@@ -1125,6 +1147,8 @@ Fixed Point Support in Clang
11251147
AST Matchers
11261148
------------
11271149

1150+
- Ensure ``hasBitWidth`` doesn't crash on bit widths that are dependent on template
1151+
parameters.
11281152
- Ensure ``isDerivedFrom`` matches the correct base in case more than one alias exists.
11291153
- Extend ``templateArgumentCountIs`` to support function and variable template
11301154
specialization.
@@ -1196,6 +1220,9 @@ New features
11961220
so frequent 'not yet implemented' diagnostics should be expected. Also, the
11971221
ACC MLIR dialect does not currently implement any lowering to LLVM-IR, so no
11981222
code generation is possible for OpenACC.
1223+
- Implemented `P2719R5 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_
1224+
as an extension in all C++ language modes.
1225+
11991226

12001227
Crash and bug fixes
12011228
^^^^^^^^^^^^^^^^^^^

clang/docs/ThinLTO.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,38 @@ The ``BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO for stage 2 and
240240
stage 3 in case the compiler used for stage 1 does not support the ThinLTO
241241
option.
242242

243+
Integrated Distributed ThinLTO (DTLTO)
244+
--------------------------------------
245+
246+
Integrated Distributed ThinLTO (DTLTO) enables the distribution of backend
247+
ThinLTO compilations via external distribution systems, such as Incredibuild,
248+
during the traditional link step.
249+
250+
The implementation is documented here: https://llvm.org/docs/DTLTO.html.
251+
252+
DTLTO requires the LLD linker (``-fuse-ld=lld``).
253+
254+
``-fthinlto-distributor=<path>``
255+
- Specifies the ``<path>`` to the distributor process executable for DTLTO.
256+
- If specified, ThinLTO backend compilations will be distributed by LLD.
257+
258+
``-Xthinlto-distributor=<arg>``
259+
- Passes ``<arg>`` to the distributor process (see ``-fthinlto-distributor=``).
260+
- Can be specified multiple times to pass multiple options.
261+
- Multiple options can also be specified by separating them with commas.
262+
263+
Examples:
264+
- ``clang -flto=thin -fthinlto-distributor=incredibuild.exe -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld``
265+
- ``clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=incredibuild.py -fuse-ld=lld``
266+
267+
If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
268+
compiler to be executed remotely to perform the ThinLTO backend
269+
compilations. Currently, this is Clang itself.
270+
271+
Note that currently, DTLTO is only supported in some LLD flavors. Support can
272+
be added to other LLD flavours in the future.
273+
See `DTLTO <https://lld.llvm.org/dtlto.html>`_ for more information.
274+
243275
More Information
244276
================
245277

0 commit comments

Comments
 (0)