Skip to content

Commit 8856e45

Browse files
committed
Merge branch 'main' into sg_distr_minor_fixes
2 parents 9520fbe + 8612926 commit 8856e45

File tree

590 files changed

+17567
-3534
lines changed

Some content is hidden

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

590 files changed

+17567
-3534
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/libclang-python-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ on:
1010
- 'main'
1111
paths:
1212
- 'clang/bindings/python/**'
13+
- 'clang/test/bindings/python/**'
1314
- 'clang/tools/libclang/**'
14-
- 'clang/CMakeList.txt'
1515
- '.github/workflows/libclang-python-tests.yml'
1616
- '.github/workflows/llvm-project-tests.yml'
1717
pull_request:
1818
paths:
1919
- 'clang/bindings/python/**'
20+
- 'clang/test/bindings/python/**'
2021
- 'clang/tools/libclang/**'
21-
- 'clang/CMakeList.txt'
2222
- '.github/workflows/libclang-python-tests.yml'
2323
- '.github/workflows/llvm-project-tests.yml'
2424

.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/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ if( CLANG_INCLUDE_TESTS )
536536
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
537537
)
538538
add_subdirectory(test)
539-
add_subdirectory(bindings/python/tests)
540539

541540
if(CLANG_BUILT_STANDALONE)
542541
umbrella_lit_testsuite_end(check-all)

clang/bindings/python/tests/CMakeLists.txt

Lines changed: 0 additions & 66 deletions
This file was deleted.
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: 25 additions & 4 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
@@ -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

@@ -950,6 +953,7 @@ Bug Fixes to C++ Support
950953
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
951954
- Correctly handles calling an explicit object member function template overload set
952955
through its address (``(&Foo::bar<baz>)()``).
956+
- Fix a crash when using an explicit object parameter in a non-member function. (#GH113185)
953957
- Fix a crash when forming an invalid call to an operator with an explicit object member. (#GH147121)
954958
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
955959
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
@@ -1024,15 +1028,29 @@ Arm and AArch64 Support
10241028
`as specified here <https://github.com/ARM-software/acle/blob/main/main/acle.md#modal-8-bit-floating-point-extensions>`_
10251029
is now available.
10261030
- Support has been added for the following processors (command-line identifiers in parentheses):
1031+
10271032
- Arm Cortex-A320 (``cortex-a320``)
1033+
10281034
- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Architecture.
10291035
- The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with
10301036
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
10311037
also now printed when the ``--print-supported-extensions`` option is used.
10321038
- When a feature that depends on NEON (``simd``) is used, NEON is now automatically enabled.
10331039
- When NEON is disabled (``+nosimd``), all features that depend on NEON will now be disabled.
10341040

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

10371055
- For AArch64, added support for generating executable-only code sections by using the
10381056
``-mexecute-only`` or ``-mpure-code`` compiler flags. (#GH125688)
@@ -1196,6 +1214,9 @@ New features
11961214
so frequent 'not yet implemented' diagnostics should be expected. Also, the
11971215
ACC MLIR dialect does not currently implement any lowering to LLVM-IR, so no
11981216
code generation is possible for OpenACC.
1217+
- Implemented `P2719R5 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_
1218+
as an extension in all C++ language modes.
1219+
11991220

12001221
Crash and bug fixes
12011222
^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)