1===========================================
2Clang |release| |ReleaseNotesTitle|
3===========================================
4
5.. contents::
6   :local:
7   :depth: 2
8
9Written by the `LLVM Team <https://llvm.org/>`_
10
11.. only:: PreRelease
12
13  .. warning::
14     These are in-progress notes for the upcoming Clang |version| release.
15     Release notes for previous releases can be found on
16     `the Download Page <https://releases.llvm.org/download.html>`_.
17
18Introduction
19============
20
21This document contains the release notes for the Clang C/C++/Objective-C
22frontend, part of the LLVM Compiler Infrastructure, release |release|. Here we
23describe the status of Clang in some detail, including major
24improvements from the previous release and new feature work. For the
25general LLVM release notes, see `the LLVM
26documentation <https://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
27releases may be downloaded from the `LLVM releases web
28site <https://llvm.org/releases/>`_.
29
30For more information about Clang or LLVM, including information about the
31latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
32`LLVM Web Site <https://llvm.org>`_.
33
34Note that if you are reading this file from a Git checkout or the
35main Clang web page, this document applies to the *next* release, not
36the current one. To see the release notes for a specific release, please
37see the `releases page <https://llvm.org/releases/>`_.
38
39What's New in Clang |release|?
40==============================
41
42Some of the major new features and improvements to Clang are listed
43here. Generic improvements to Clang as a whole or to its underlying
44infrastructure are described first, followed by language-specific
45sections with improvements to Clang's support for those languages.
46
47Major New Features
48------------------
49
50- Clang now supports the ``-fzero-call-used-regs`` feature for x86. The purpose
51  of this feature is to limit Return-Oriented Programming (ROP) exploits and
52  information leakage. It works by zeroing out a selected class of registers
53  before function return --- e.g., all GPRs that are used within the function.
54  There is an analogous ``zero_call_used_regs`` attribute to allow for finer
55  control of this feature.
56
57- Clang now supports randomizing structure layout in C. This feature is a
58  compile-time hardening technique, making it more difficult for an attacker to
59  retrieve data from structures. Specify randomization with the
60  ``randomize_layout`` attribute. The corresponding ``no_randomize_layout``
61  attribute can be used to turn the feature off.
62
63  A seed value is required to enable randomization, and is deterministic based
64  on a seed value. Use the ``-frandomize-layout-seed=`` or
65  ``-frandomize-layout-seed-file=`` flags.
66
67  .. note::
68
69      Randomizing structure layout is a C-only feature.
70
71- Clang now supports the ``-fstrict-flex-arrays=<arg>`` option to control which
72  array bounds lead to flexible array members. The option yields more accurate
73  ``__builtin_object_size`` and ``__builtin_dynamic_object_size`` results in
74  most cases but may be overly conservative for some legacy code.
75- Experimental support for HLSL has been added. The implementation is
76  incomplete and highly experimental. For more information about the ongoing
77  work to support HLSL see the `documentation
78  <https://clang.llvm.org/docs/HLSLSupport.html>`_, or the `GitHub project
79  <https://github.com/orgs/llvm/projects/4>`_.
80
81Bug Fixes
82---------
83- ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
84  wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
85  size expression. This was fixed and ``::getArraySize()`` will now always
86  either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
87  This fixes `Issue 53742 <https://github.com/llvm/llvm-project/issues/53742>`_.
88- We now ignore full expressions when traversing cast subexpressions. This
89  fixes `Issue 53044 <https://github.com/llvm/llvm-project/issues/53044>`_.
90- Allow ``-Wno-gnu`` to silence GNU extension diagnostics for pointer
91  arithmetic diagnostics. Fixes `Issue 54444
92  <https://github.com/llvm/llvm-project/issues/54444>`_.
93- Placeholder constraints, as in ``Concept auto x = f();``, were not checked
94  when modifiers like ``auto&`` or ``auto**`` were added. These constraints are
95  now checked.
96  This fixes  `Issue 53911 <https://github.com/llvm/llvm-project/issues/53911>`_
97  and  `Issue 54443 <https://github.com/llvm/llvm-project/issues/54443>`_.
98- Previously invalid member variables with template parameters would crash clang.
99  Now fixed by setting identifiers for them.
100  This fixes `Issue 28475 (PR28101) <https://github.com/llvm/llvm-project/issues/28475>`_.
101- Now allow the ``restrict`` and ``_Atomic`` qualifiers to be used in
102  conjunction with ``__auto_type`` to match the behavior in GCC. This fixes
103  `Issue 53652 <https://github.com/llvm/llvm-project/issues/53652>`_.
104- No longer crash when specifying a variably-modified parameter type in a
105  function with the ``naked`` attribute. This fixes
106  `Issue 50541 <https://github.com/llvm/llvm-project/issues/50541>`_.
107- Allow multiple ``#pragma weak`` directives to name the same undeclared (if an
108  alias, target) identifier instead of only processing one such ``#pragma weak``
109  per identifier.
110  Fixes `Issue 28985 <https://github.com/llvm/llvm-project/issues/28985>`_.
111- Assignment expressions in C11 and later mode now properly strip the _Atomic
112  qualifier when determining the type of the assignment expression. Fixes
113  `Issue 48742 <https://github.com/llvm/llvm-project/issues/48742>`_.
114- Improved the diagnostic when accessing a member of an atomic structure or
115  union object in C; was previously an unhelpful error, but now issues a
116  ``-Watomic-access`` warning which defaults to an error. Fixes
117  `Issue 54563 <https://github.com/llvm/llvm-project/issues/54563>`_.
118- Unevaluated lambdas in dependant contexts no longer result in clang crashing.
119  This fixes Issues `50376 <https://github.com/llvm/llvm-project/issues/50376>`_,
120  `51414 <https://github.com/llvm/llvm-project/issues/51414>`_,
121  `51416 <https://github.com/llvm/llvm-project/issues/51416>`_,
122  and `51641 <https://github.com/llvm/llvm-project/issues/51641>`_.
123- The builtin function __builtin_dump_struct would crash clang when the target
124  struct contains a bitfield. It now correctly handles bitfields.
125  This fixes Issue `Issue 54462 <https://github.com/llvm/llvm-project/issues/54462>`_.
126- Statement expressions are now disabled in default arguments in general.
127  This fixes Issue `Issue 53488 <https://github.com/llvm/llvm-project/issues/53488>`_.
128- According to `CWG 1394 <https://wg21.link/cwg1394>`_ and
129  `C++20 [dcl.fct.def.general]p2 <https://timsong-cpp.github.io/cppwp/n4868/dcl.fct.def#general-2.sentence-3>`_,
130  Clang should not diagnose incomplete types in function definitions if the function body is "= delete;".
131  This fixes Issue `Issue 52802 <https://github.com/llvm/llvm-project/issues/52802>`_.
132- Unknown type attributes with a ``[[]]`` spelling are no longer diagnosed twice.
133  This fixes Issue `Issue 54817 <https://github.com/llvm/llvm-project/issues/54817>`_.
134- Clang should no longer incorrectly diagnose a variable declaration inside of
135  a lambda expression that shares the name of a variable in a containing
136  if/while/for/switch init statement as a redeclaration.
137  This fixes `Issue 54913 <https://github.com/llvm/llvm-project/issues/54913>`_.
138- Overload resolution for constrained function templates could use the partial
139  order of constraints to select an overload, even if the parameter types of
140  the functions were different. It now diagnoses this case correctly as an
141  ambiguous call and an error. Fixes
142  `Issue 53640 <https://github.com/llvm/llvm-project/issues/53640>`_.
143- No longer crash when trying to determine whether the controlling expression
144  argument to a generic selection expression has side effects in the case where
145  the expression is result dependent. This fixes
146  `Issue 50227 <https://github.com/llvm/llvm-project/issues/50227>`_.
147- Fixed an assertion when constant evaluating an initializer for a GCC/Clang
148  floating-point vector type when the width of the initialization is exactly
149  the same as the elements of the vector being initialized.
150  Fixes `Issue 50216 <https://github.com/llvm/llvm-project/issues/50216>`_.
151- Fixed a crash when the ``__bf16`` type is used such that its size or
152  alignment is calculated on a target which does not support that type. This
153  fixes `Issue 50171 <https://github.com/llvm/llvm-project/issues/50171>`_.
154- Fixed a false positive diagnostic about an unevaluated expression having no
155  side effects when the expression is of VLA type and is an operand of the
156  ``sizeof`` operator. Fixes `Issue 48010 <https://github.com/llvm/llvm-project/issues/48010>`_.
157- Fixed a false positive diagnostic about scoped enumerations being a C++11
158  extension in C mode. A scoped enumeration's enumerators cannot be named in C
159  because there is no way to fully qualify the enumerator name, so this
160  "extension" was unintentional and useless. This fixes
161  `Issue 42372 <https://github.com/llvm/llvm-project/issues/42372>`_.
162- Clang will now find and emit a call to an allocation function in a
163  promise_type body for coroutines if there is any allocation function
164  declaration in the scope of promise_type. Additionally, to implement CWG2585,
165  a coroutine will no longer generate a call to a global allocation function
166  with the signature (std::size_t, p0, ..., pn).
167  This fixes Issue `Issue 54881 <https://github.com/llvm/llvm-project/issues/54881>`_.
168- Implement `CWG 2394 <https://wg21.link/cwg2394>`_: Const class members
169  may be initialized with a defaulted default constructor under the same
170  conditions it would be allowed for a const object elsewhere.
171- ``__has_unique_object_representations`` no longer reports that ``_BitInt`` types
172  have unique object representations if they have padding bits.
173- Unscoped and scoped enumeration types can no longer be initialized from a
174  brace-init-list containing a single element of a different scoped enumeration
175  type.
176- Allow use of an elaborated type specifier as a ``_Generic`` selection
177  association in C++ mode. This fixes
178  `Issue 55562 <https://github.com/llvm/llvm-project/issues/55562>`_.
179- Clang will allow calling a ``consteval`` function in a default argument. This
180  fixes `Issue 48230 <https://github.com/llvm/llvm-project/issues/48230>`_.
181- Fixed memory leak due to ``VarTemplateSpecializationDecl`` using
182  ``TemplateArgumentListInfo`` instead of ``ASTTemplateArgumentListInfo``.
183- An initializer for a static variable declaration, which is nested
184  inside a statement expression in an aggregate initializer, is now
185  emitted as a dynamic initializer. Previously the variable would
186  incorrectly be zero-initialized. In contexts where a dynamic
187  initializer is not allowed this is now diagnosed as an error.
188- Clang now correctly emits symbols for implicitly instantiated constexpr
189  template function. Fixes `Issue 55560 <https://github.com/llvm/llvm-project/issues/55560>`_.
190- Clang now checks ODR violations when merging concepts from different modules.
191  Note that this may possibly break existing code, and is done so intentionally.
192  Fixes `Issue 56310 <https://github.com/llvm/llvm-project/issues/56310>`_.
193- Clang will now look through type sugar when checking a member function is a
194  move assignment operator. Fixes `Issue 56456 <https://github.com/llvm/llvm-project/issues/56456>`_.
195
196Improvements to Clang's diagnostics
197^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198- ``-Wliteral-range`` will warn on floating-point equality comparisons with
199  constants that are not representable in a casted value. For example,
200  ``(float) f == 0.1`` is always false.
201- ``-Winline-namespace-reopened-noninline`` now takes into account that the
202  ``inline`` keyword must appear on the original but not necessarily all
203  extension definitions of an inline namespace and therefore points its note
204  at the original definition. This fixes `Issue 50794 (PR51452)
205  <https://github.com/llvm/llvm-project/issues/50794>`_.
206- ``-Wunused-but-set-variable`` now also warns if the variable is only used
207  by unary operators.
208- ``-Wunused-variable`` no longer warn for references extending the lifetime
209  of temporaries with side effects. This fixes `Issue 54489
210  <https://github.com/llvm/llvm-project/issues/54489>`_.
211- Modified the behavior of ``-Wstrict-prototypes`` and added a new, related
212  diagnostic ``-Wdeprecated-non-prototype``. The strict prototypes warning will
213  now only diagnose deprecated declarations and definitions of functions
214  without a prototype where the behavior in C2x will remain correct. This
215  diagnostic remains off by default but is now enabled via ``-pedantic`` due to
216  it being a deprecation warning. ``-Wstrict-prototypes`` has no effect in C2x
217  or when ``-fno-knr-functions`` is enabled. ``-Wdeprecated-non-prototype``
218  will diagnose cases where the deprecated declarations or definitions of a
219  function without a prototype will change behavior in C2x. Additionally, it
220  will diagnose calls which pass arguments to a function without a prototype.
221  This warning is enabled only when the ``-Wdeprecated-non-prototype`` option
222  is enabled at the function declaration site, which allows a developer to
223  disable the diagnostic for all callers at the point of declaration. This
224  diagnostic is grouped under the ``-Wstrict-prototypes`` warning group, but is
225  enabled by default. ``-Wdeprecated-non-prototype`` has no effect in C2x or
226  when ``-fno-knr-functions`` is enabled.
227- Clang now appropriately issues an error in C when a definition of a function
228  without a prototype and with no arguments is an invalid redeclaration of a
229  function with a prototype. e.g., ``void f(int); void f() {}`` is now properly
230  diagnosed.
231- The ``-Wimplicit-function-declaration`` warning diagnostic now defaults to
232  an error in C99 and later. Prior to C2x, it may be downgraded to a warning
233  with ``-Wno-error=implicit-function-declaration``, or disabled entirely with
234  ``-Wno-implicit-function-declaration``. As of C2x, support for implicit
235  function declarations has been removed, and the warning options will have no
236  effect.
237- The ``-Wimplicit-int`` warning diagnostic now defaults to an error in C99 and
238  later. Prior to C2x, it may be downgraded to a warning with
239  ``-Wno-error=implicit-int``, or disabled entirely with ``-Wno-implicit-int``.
240  As of C2x, support for implicit int has been removed, and the warning options
241  will have no effect. Specifying ``-Wimplicit-int`` in C89 mode will now issue
242  warnings instead of being a noop.
243- No longer issue a "declaration specifiers missing, defaulting to int"
244  diagnostic in C89 mode because it is not an extension in C89, it was valid
245  code. The diagnostic has been removed entirely as it did not have a
246  diagnostic group to disable it, but it can be covered wholly by
247  ``-Wimplicit-int``.
248- ``-Wmisexpect`` warns when the branch weights collected during profiling
249  conflict with those added by ``llvm.expect``.
250- ``-Wthread-safety-analysis`` now considers overloaded compound assignment and
251  increment/decrement operators as writing to their first argument, thus
252  requiring an exclusive lock if the argument is guarded.
253- ``-Wenum-conversion`` now warns on converting a signed enum of one type to an
254  unsigned enum of a different type (or vice versa) rather than
255  ``-Wsign-conversion``.
256- Added the ``-Wunreachable-code-generic-assoc`` diagnostic flag (grouped under
257  the ``-Wunreachable-code`` flag) which is enabled by default and warns the
258  user about ``_Generic`` selection associations which are unreachable because
259  the type specified is an array type or a qualified type.
260- Added the ``-Wgnu-line-marker`` diagnostic flag (grouped under the ``-Wgnu``
261  flag) which is a portability warning about use of GNU linemarker preprocessor
262  directives. Fixes `Issue 55067 <https://github.com/llvm/llvm-project/issues/55067>`_.
263- Using ``#elifdef`` and ``#elifndef`` that are incompatible with C/C++
264  standards before C2x/C++2b are now warned via ``-pedantic``. Additionally,
265  on such language mode, ``-Wpre-c2x-compat`` and ``-Wpre-c++2b-compat``
266  diagnostic flags report a compatibility issue.
267  Fixes `Issue 55306 <https://github.com/llvm/llvm-project/issues/55306>`_.
268- Clang now checks for stack resource exhaustion when recursively parsing
269  declarators in order to give a diagnostic before we run out of stack space.
270  This fixes `Issue 51642 <https://github.com/llvm/llvm-project/issues/51642>`_.
271- Unknown preprocessor directives in a skipped conditional block are now given
272  a typo correction suggestion if the given directive is sufficiently similar
273  to another preprocessor conditional directive. For example, if ``#esle``
274  appears in a skipped block, we will warn about the unknown directive and
275  suggest ``#else`` as an alternative. ``#elifdef`` and ``#elifndef`` are only
276  suggested when in C2x or C++2b mode. Fixes
277  `Issue 51598 <https://github.com/llvm/llvm-project/issues/51598>`_.
278- The ``-Wdeprecated`` diagnostic will now warn on out-of-line ``constexpr``
279  declarations downgraded to definitions in C++1z, in addition to the
280  existing warning on out-of-line ``const`` declarations.
281- ``-Wshift-overflow`` will not warn for signed left shifts in C++20 mode
282  (and newer), as it will always wrap and never overflow. This fixes
283  `Issue 52873 <https://github.com/llvm/llvm-project/issues/52873>`_.
284- When using class templates without arguments, clang now tells developers
285  that template arguments are missing in certain contexts.
286  This fixes `Issue 55962 <https://github.com/llvm/llvm-project/issues/55962>`_.
287- Printable Unicode characters within `static_assert` messages are no longer
288  escaped.
289- The ``-Winfinite-recursion`` diagnostic no longer warns about
290  unevaluated operands of a ``typeid`` expression, as they are now
291  modeled correctly in the CFG. This fixes
292  `Issue 21668 <https://github.com/llvm/llvm-project/issues/21668>`_.
293- ``-Wself-assign``, ``-Wself-assign-overloaded`` and ``-Wself-move`` will
294  suggest a fix if the decl being assigned is a parameter that shadows a data
295  member of the contained class.
296- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
297  comments.
298
299Non-comprehensive list of changes in this release
300-------------------------------------------------
301
302- Improve __builtin_dump_struct:
303
304  - Support bitfields in struct and union.
305  - Improve the dump format, dump both bitwidth(if its a bitfield) and field
306    value.
307  - Remove anonymous tag locations and flatten anonymous struct members.
308  - Beautify dump format, add indent for struct members.
309  - Support passing additional arguments to the formatting function, allowing
310    use with ``fprintf`` and similar formatting functions.
311  - Support use within constant evaluation in C++, if a ``constexpr``
312    formatting function is provided.
313  - Support formatting of base classes in C++.
314  - Support calling a formatting function template in C++, which can provide
315    custom formatting for non-aggregate types.
316
317- Previously disabled sanitizer options now enabled by default:
318  - ASAN_OPTIONS=detect_stack_use_after_return=1 (only on Linux).
319  - MSAN_OPTIONS=poison_in_dtor=1.
320
321- Some type-trait builtins, such as ``__has_trivial_assign``, have been documented
322  as deprecated for a while because their semantics don't mix well with post-C++11 type-traits.
323  Clang now emits deprecation warnings for them under the flag ``-Wdeprecated-builtins``.
324
325New Compiler Flags
326------------------
327- Added the ``-fno-knr-functions`` flag to allow users to opt into the C2x
328  behavior where a function with an empty parameter list is treated as though
329  the parameter list were ``void``. There is no ``-fknr-functions`` or
330  ``-fno-no-knr-functions`` flag; this feature cannot be disabled in language
331  modes where it is required, such as C++ or C2x.
332- A new ARM pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72 Erratum
333  1655431 can be enabled using ``-mfix-cortex-a57-aes-1742098`` or
334  ``-mfix-cortex-a72-aes-1655431``. The pass is enabled when using either of
335  these cpus with ``-mcpu=`` and can be disabled using
336  ``-mno-fix-cortex-a57-aes-1742098`` or ``-mno-fix-cortex-a72-aes-1655431``.
337- Added the ``-fexperimental-max-bitint-width=`` option to increase the maximum
338  allowed bit width of ``_BitInt`` types beyond the default of 128 bits. Some
339  operations, such as division or float-to-integer conversion, on ``_BitInt``
340  types with more than 128 bits currently crash clang. This option will be
341  removed in the future once clang supports all such operations.
342- Added the ``-print-diagnostic-options`` option, which prints a list of
343  warnings the compiler supports.
344- Added the ``-Warray-parameter`` warning. It diagnoses differences between
345  array parameters between function redeclarations (arrays of different extents,
346  etc). This flag is related to the same flag in GCC, but is different in that
347  it does not accept an explicitly- specified warning level and use of this flag
348  has no effect on ``-Warray-bounds``.
349
350Deprecated Compiler Flags
351-------------------------
352
353Modified Compiler Flags
354-----------------------
355
356Removed Compiler Flags
357-------------------------
358- Removed the ``-fno-concept-satisfaction-caching`` flag. The flag was added
359  at the time when the draft of C++20 standard did not permit caching of
360  atomic constraints. The final standard permits such caching, see
361  `WG21 P2104R0 <http://wg21.link/p2104r0>`_.
362
363New Pragmas in Clang
364--------------------
365- Added support for MSVC's ``#pragma function``, which tells the compiler to
366  generate calls to functions listed in the pragma instead of using the
367  builtins.
368- Added support for MSVC's ``#pragma alloc_text``. The pragma names the code
369  section functions are placed in. The pragma only applies to functions with
370  C linkage.
371- Added support for an empty optimization list for MSVC's ``#pragma optimize``.
372  The pragma takes a list of optimizations to turn on or off which applies to
373  all functions following the pragma. At the moment, only an empty list is
374  supported.
375
376- ...
377
378Attribute Changes in Clang
379--------------------------
380
381- Added support for parameter pack expansion in ``clang::annotate``.
382
383- The ``overloadable`` attribute can now be written in all of the syntactic
384  locations a declaration attribute may appear.
385  This fixes `Issue 53805 <https://github.com/llvm/llvm-project/issues/53805>`_.
386
387- Improved namespace attributes handling:
388
389  - Handle GNU attributes before a namespace identifier and subsequent
390    attributes of different kinds.
391  - Emit error on GNU attributes for a nested namespace definition.
392
393- Statement attributes ``[[clang::noinline]]`` and  ``[[clang::always_inline]]``
394  can be used to control inlining decisions at callsites.
395
396- ``#pragma clang attribute push`` now supports multiple attributes within a single directive.
397
398- The ``__declspec(naked)`` attribute can no longer be written on a member
399  function in Microsoft compatibility mode, matching the behavior of cl.exe.
400
401- Attribute ``no_builtin`` should now affect the generated code. It now disables
402  builtins (corresponding to the specific names listed in the attribute) in the
403  body of the function the attribute is on.
404
405- When the ``weak`` attribute is applied to a const qualified variable clang no longer
406  tells the backend it is allowed to optimize based on initializer value.
407
408- Added the ``clang::annotate_type`` attribute, which can be used to add
409  annotations to types (see documentation for details).
410
411- Added half float to types that can be represented by ``__attribute__((mode(XX)))``.
412
413- The ``format`` attribute can now be applied to non-variadic functions. The
414  format string must correctly format the fixed parameter types of the function.
415  Using the attribute this way emits a GCC compatibility diagnostic.
416
417- Support was added for ``__attribute__((function_return("thunk-extern")))``
418  to X86 to replace ``ret`` instructions with ``jmp __x86_return_thunk``. The
419  corresponding attribute to disable this,
420  ``__attribute__((function_return("keep")))`` was added. This is intended to
421  be used by the Linux kernel to mitigate RETBLEED.
422
423Windows Support
424---------------
425
426- Add support for MSVC-compatible ``/JMC``/``/JMC-`` flag in clang-cl (supports
427  X86/X64/ARM/ARM64). ``/JMC`` could only be used when ``/Zi`` or ``/Z7`` is
428  turned on. With this addition, clang-cl can be used in Visual Studio for the
429  JustMyCode feature. Note, you may need to manually add ``/JMC`` as additional
430  compile options in the Visual Studio since it currently assumes clang-cl does not support ``/JMC``.
431
432- Implemented generation of SEH unwind information on ARM. (C++ exception
433  handling in MSVC mode is still unimplemented though.)
434
435- Switched MinGW mode on ARM to use SEH instead of DWARF for unwind information.
436
437AIX Support
438-----------
439
440- The driver no longer adds ``-mignore-xcoff-visibility`` by default for AIX
441  targets when no other visibility command-line options are in effect, as
442  ignoring hidden visibility can silently have undesirable side effects (e.g
443  when libraries depend on visibility to hide non-ABI facing entities). The
444  ``-mignore-xcoff-visibility`` option can be manually specified on the
445  command-line to recover the previous behavior if desired.
446
447C Language Changes in Clang
448---------------------------
449
450C2x Feature Support
451-------------------
452
453- Implemented `WG14 N2674 The noreturn attribute <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf>`_.
454- Implemented `WG14 N2935 Make false and true first-class language features <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2935.pdf>`_.
455- Implemented `WG14 N2763 Adding a fundamental type for N-bit integers <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf>`_.
456- Implemented `WG14 N2775 Literal suffixes for bit-precise integers <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf>`_.
457- Implemented the ``*_WIDTH`` macros to complete support for
458  `WG14 N2412 Two's complement sign representation for C2x <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf>`_.
459- Implemented `WG14 N2418 Adding the u8 character prefix <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2418.pdf>`_.
460- Removed support for implicit function declarations. This was a C89 feature
461  that was removed in C99, but cannot be supported in C2x because it requires
462  support for functions without prototypes, which no longer exist in C2x.
463- Implemented `WG14 N2841 No function declarators without prototypes <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm>`_
464  and `WG14 N2432 Remove support for function definitions with identifier lists <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf>`_.
465
466C++ Language Changes in Clang
467-----------------------------
468
469- Improved ``-O0`` code generation for calls to ``std::move``, ``std::forward``,
470  ``std::move_if_noexcept``, ``std::addressof``, and ``std::as_const``. These
471  are now treated as compiler builtins and implemented directly, rather than
472  instantiating the definition from the standard library.
473- Fixed mangling of nested dependent names such as ``T::a::b``, where ``T`` is a
474  template parameter, to conform to the Itanium C++ ABI and be compatible with
475  GCC. This breaks binary compatibility with code compiled with earlier versions
476  of clang; use the ``-fclang-abi-compat=14`` option to get the old mangling.
477- Preprocessor character literals with a ``u8`` prefix are now correctly treated as
478  unsigned character literals. This fixes `Issue 54886 <https://github.com/llvm/llvm-project/issues/54886>`_.
479- Stopped allowing constraints on non-template functions to be compliant with
480  dcl.decl.general p4.
481
482C++20 Feature Support
483^^^^^^^^^^^^^^^^^^^^^
484- Diagnose consteval and constexpr issues that happen at namespace scope. This
485  partially addresses `Issue 51593 <https://github.com/llvm/llvm-project/issues/51593>`_.
486- No longer attempt to evaluate a consteval UDL function call at runtime when
487  it is called through a template instantiation. This fixes
488  `Issue 54578 <https://github.com/llvm/llvm-project/issues/54578>`_.
489
490- Implemented ``__builtin_source_location()``, which enables library support
491  for ``std::source_location``.
492
493- The mangling scheme for C++20 modules has incompatibly changed. The
494  initial mangling was discovered not to be reversible, and the weak
495  ownership design decision did not give the backwards compatibility
496  that was hoped for. C++20 since added ``extern "C++"`` semantics
497  that can be used for such compatibility. The demangler now demangles
498  symbols with named module attachment.
499
500- As per "Conditionally Trivial Special Member Functions" (P0848), it is
501  now possible to overload destructors using concepts. Note that the rest
502  of the paper about other special member functions is not yet implemented.
503
504C++2b Feature Support
505^^^^^^^^^^^^^^^^^^^^^
506
507- Implemented `P2128R6: Multidimensional subscript operator <https://wg21.link/P2128R6>`_.
508- Implemented `P0849R8: auto(x): decay-copy in the language <https://wg21.link/P0849R8>`_.
509- Implemented `P2242R3: Non-literal variables (and labels and gotos) in constexpr functions	<https://wg21.link/P2242R3>`_.
510- Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation <https://wg21.link/LWG3659>`_.
511- Implemented `P2290 Delimited escape sequences <https://wg21.link/P2290R3>`_.
512  This feature is available as an extension in all C and C++ language modes.
513- Implemented `P2071 Named universal character escapes <https://wg21.link/P2290R2>`_.
514  This feature is available as an extension in all C and C++ language modes.
515
516CUDA/HIP Language Changes in Clang
517----------------------------------
518
519- Added `__noinline__` as a keyword to avoid diagnostics due to usage of
520  `__attribute__((__noinline__))` in CUDA/HIP programs.
521
522Objective-C Language Changes in Clang
523-------------------------------------
524
525OpenCL C Language Changes in Clang
526----------------------------------
527
528...
529
530ABI Changes in Clang
531--------------------
532
533- GCC doesn't pack non-POD members in packed structs unless the packed
534  attribute is also specified on the member. Clang historically did perform
535  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
536  You can switch back to the old ABI behavior with the flag:
537  ``-fclang-abi-compat=14.0``.
538- When compiling C for ARM or AArch64, a zero-length bitfield in a ``struct``
539  (e.g. ``int : 0``) no longer prevents the structure from being considered a
540  homogeneous floating-point or vector aggregate. The new behavior agrees with
541  the AAPCS specification, and matches the similar bug fix in GCC 12.1.
542- Targeting AArch64, since D127209 LLVM now only preserves the z8-z23
543  and p4-p15 registers across a call if the registers z0-z7 or p0-p3 are
544  used to pass data into or out of a subroutine. The new behavior
545  matches the AAPCS. Previously LLVM preserved z8-z23 and p4-p15 across
546  a call if the callee had an SVE type anywhere in its signature. This
547  would cause an incorrect use of the caller-preserved z8-z23 and p4-p15
548  ABI for example if the 9th argument or greater were the first SVE type
549  in the signature of a function.
550- All copy constructors can now be trivial if they are not user-provided,
551  regardless of the type qualifiers of the argument of the defaulted constructor,
552  fixing dr2171.
553  You can switch back to the old ABI behavior with the flag:
554  ``-fclang-abi-compat=14.0``.
555
556OpenMP Support in Clang
557-----------------------
558
559...
560
561CUDA Support in Clang
562---------------------
563
564- ...
565
566X86 Support in Clang
567--------------------
568
569- Support ``-mharden-sls=[none|all|return|indirect-jmp]`` for straight-line
570  speculation hardening.
571- Support for the ``_Float16`` type has been added for all targets with SSE2.
572  When AVX512-FP16 is not available, arithmetic on ``_Float16`` is emulated
573  using ``float``.
574- Added the ``-m[no-]rdpru`` flag to enable/disable the RDPRU instruction
575  provided by AMD Zen2 and later processors. Defined intrinsics for using
576  this instruction (see rdpruintrin.h).
577- Support ``-mstack-protector-guard-symbol=[SymbolName]`` to use the given
578  symbol for addressing the stack protector guard.
579- ``-mfunction-return=thunk-extern`` support was added to clang for x86. This
580  will be used by Linux kernel mitigations for RETBLEED. The corresponding flag
581  ``-mfunction-return=keep`` may be appended to disable the feature.
582
583DWARF Support in Clang
584----------------------
585
586- clang now adds DWARF information for inline strings in C/C++ programs,
587  allowing ``line:column`` symbolization of strings. Some debugging programs may
588  require updating, as this takes advantage of DWARF ``DW_TAG_variable``
589  structures *without* a ``DW_AT_name`` field, which is valid DWARF, but may be
590  handled incorrectly by some software (e.g. new failures with incorrect
591  assertions).
592
593Arm and AArch64 Support in Clang
594--------------------------------
595
596- clang now supports the Cortex-M85 CPU, which can be chosen with
597  `-mcpu=cortex-m85`. By default, this has PACBTI turned on, but it can be
598  disabled with `-mcpu=cortex-m85+nopacbti`.
599
600Floating Point Support in Clang
601-------------------------------
602
603Internal API Changes
604--------------------
605
606- Added a new attribute flag ``AcceptsExprPack`` that when set allows
607  expression pack expansions in the parsed arguments of the corresponding
608  attribute. Additionally it introduces delaying of attribute arguments, adding
609  common handling for creating attributes that cannot be fully initialized
610  prior to template instantiation.
611
612Build System Changes
613--------------------
614
615* CMake ``-DCLANG_DEFAULT_PIE_ON_LINUX=ON`` is now the default. This is used by
616  linux-gnu systems to decide whether ``-fPIE -pie`` is the default (instead of
617  ``-fno-pic -no-pie``). This matches GCC installations on many Linux distros.
618  Note: linux-android and linux-musl always default to ``-fPIE -pie``, ignoring
619  this variable. ``-DCLANG_DEFAULT_PIE_ON_LINUX`` may be removed in the future.
620
621AST Matchers
622------------
623
624- Expanded ``isInline`` narrowing matcher to support C++17 inline variables.
625
626- Added ``forEachTemplateArgument`` matcher which creates a match every
627  time a ``templateArgument`` matches the matcher supplied to it.
628
629- Added ``objcStringLiteral`` matcher which matches ObjectiveC String
630  literal expressions.
631
632clang-format
633------------
634
635- **Important change**: Renamed ``IndentRequires`` to ``IndentRequiresClause``
636  and changed the default for all styles from ``false`` to ``true``.
637
638- Reworked and improved handling of concepts and requires. Added the
639  ``RequiresClausePosition`` option as part of that.
640
641- Changed ``BreakBeforeConceptDeclarations`` from ``Boolean`` to an enum.
642
643- Option ``InsertBraces`` has been added to insert optional braces after control
644  statements.
645
646clang-extdef-mapping
647--------------------
648
649- clang-extdef-mapping now accepts .ast files as input. This is faster than to
650  recompile the files from sources when extracting method definitons. This can
651  be really beneficial when creating .ast files for input to the clang-static-analyzer.
652
653libclang
654--------
655
656- ...
657
658Static Analyzer
659---------------
660- `New CTU implementation
661  <https://discourse.llvm.org/t/rfc-much-faster-cross-translation-unit-ctu-analysis-implementation/61728>`_
662  that keeps the slow-down around 2x compared to the single-TU analysis, even
663  in case of complex C++ projects. Still, it finds the majority of the "old"
664  CTU findings. Besides, not more than ~3% of the bug reports are lost compared
665  to single-TU analysis, the lost reports are highly likely to be false
666  positives.
667
668- Added a new checker ``alpha.unix.cstring.UninitializedRead`` this will check for uninitialized reads
669  from common memory copy/manipulation functions such as ``memcpy``, ``mempcpy``, ``memmove``, ``memcmp``, `
670  `strcmp``, ``strncmp``, ``strcpy``, ``strlen``, ``strsep`` and many more. Although
671  this checker currently is in list of alpha checkers due to a false positive.
672
673- Added a new checker ``alpha.unix.Errno``. This can find the first read
674  of ``errno`` after successful standard function calls, such use of ``errno``
675  could be unsafe.
676
677- Deprecate the ``-analyzer-store region`` and
678  ``-analyzer-opt-analyze-nested-blocks`` analyzer flags.
679  These flags are still accepted, but a warning will be displayed.
680  These flags will be rejected, thus turned into a hard error starting with
681  ``clang-16``.
682
683.. _release-notes-ubsan:
684
685Undefined Behavior Sanitizer (UBSan)
686------------------------------------
687
688Core Analysis Improvements
689==========================
690
691- ...
692
693New Issues Found
694================
695
696- ...
697
698Python Binding Changes
699----------------------
700
701The following methods have been added:
702
703-  ...
704
705Significant Known Problems
706==========================
707
708Additional Information
709======================
710
711A wide variety of additional information is available on the `Clang web
712page <https://clang.llvm.org/>`_. The web page contains versions of the
713API documentation which are up-to-date with the Git version of
714the source code. You can access versions of these documents specific to
715this release by going into the "``clang/docs/``" directory in the Clang
716tree.
717
718If you have any questions or comments about Clang, please feel free to
719contact us on the Discourse forums (Clang Frontend category)
720<https://discourse.llvm.org/c/clang/6>`_.
721