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
71Bug Fixes
72------------------
73- ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
74  wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
75  size expression. This was fixed and ``::getArraySize()`` will now always
76  either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
77  This fixes `Issue 53742 <https://github.com/llvm/llvm-project/issues/53742>`_.
78- We now ignore full expressions when traversing cast subexpressions. This
79  fixes `Issue 53044 <https://github.com/llvm/llvm-project/issues/53044>`_.
80- Allow `-Wno-gnu` to silence GNU extension diagnostics for pointer arithmetic
81  diagnostics. Fixes `Issue 54444 <https://github.com/llvm/llvm-project/issues/54444>`_.
82- Placeholder constraints, as in `Concept auto x = f();`, were not checked when modifiers
83  like ``auto&`` or ``auto**`` were added. These constraints are now checked.
84  This fixes  `Issue 53911 <https://github.com/llvm/llvm-project/issues/53911>`_
85  and  `Issue 54443 <https://github.com/llvm/llvm-project/issues/54443>`_.
86- Previously invalid member variables with template parameters would crash clang.
87  Now fixed by setting identifiers for them.
88  This fixes `Issue 28475 (PR28101) <https://github.com/llvm/llvm-project/issues/28475>`_.
89- Now allow the `restrict` and `_Atomic` qualifiers to be used in conjunction
90  with `__auto_type` to match the behavior in GCC. This fixes
91  `Issue 53652 <https://github.com/llvm/llvm-project/issues/53652>`_.
92- No longer crash when specifying a variably-modified parameter type in a
93  function with the ``naked`` attribute. This fixes
94  `Issue 50541 <https://github.com/llvm/llvm-project/issues/50541>`_.
95- Allow multiple ``#pragma weak`` directives to name the same undeclared (if an
96  alias, target) identifier instead of only processing one such ``#pragma weak``
97  per identifier.
98  Fixes `Issue 28985 <https://github.com/llvm/llvm-project/issues/28985>`_.
99- Assignment expressions in C11 and later mode now properly strip the _Atomic
100  qualifier when determining the type of the assignment expression. Fixes
101  `Issue 48742 <https://github.com/llvm/llvm-project/issues/48742>`_.
102- Improved the diagnostic when accessing a member of an atomic structure or
103  union object in C; was previously an unhelpful error, but now issues a
104  `-Watomic-access` warning which defaults to an error. Fixes
105  `Issue 54563 <https://github.com/llvm/llvm-project/issues/54563>`_.
106- Unevaluated lambdas in dependant contexts no longer result in clang crashing.
107  This fixes Issues `50376 <https://github.com/llvm/llvm-project/issues/50376>`_,
108  `51414 <https://github.com/llvm/llvm-project/issues/51414>`_,
109  `51416 <https://github.com/llvm/llvm-project/issues/51416>`_,
110  and `51641 <https://github.com/llvm/llvm-project/issues/51641>`_.
111- The builtin function __builtin_dump_struct would crash clang when the target
112  struct contains a bitfield. It now correctly handles bitfields.
113  This fixes Issue `Issue 54462 <https://github.com/llvm/llvm-project/issues/54462>`_.
114- Statement expressions are now disabled in default arguments in general.
115  This fixes Issue `Issue 53488 <https://github.com/llvm/llvm-project/issues/53488>`_.
116- According to `CWG 1394 <https://wg21.link/cwg1394>`_ and
117  `C++20 [dcl.fct.def.general]p2 <https://timsong-cpp.github.io/cppwp/n4868/dcl.fct.def#general-2.sentence-3>`_,
118  Clang should not diagnose incomplete types in function definitions if the function body is "= delete;".
119  This fixes Issue `Issue 52802 <https://github.com/llvm/llvm-project/issues/52802>`_.
120- Unknown type attributes with a ``[[]]`` spelling are no longer diagnosed twice.
121  This fixes Issue `Issue 54817 <https://github.com/llvm/llvm-project/issues/54817>`_.
122- Clang should no longer incorrectly diagnose a variable declaration inside of
123  a lambda expression that shares the name of a variable in a containing
124  if/while/for/switch init statement as a redeclaration.
125  This fixes `Issue 54913 <https://github.com/llvm/llvm-project/issues/54913>`_.
126- Overload resolution for constrained function templates could use the partial
127  order of constraints to select an overload, even if the parameter types of
128  the functions were different. It now diagnoses this case correctly as an
129  ambiguous call and an error. Fixes
130  `Issue 53640 <https://github.com/llvm/llvm-project/issues/53640>`_.
131
132Improvements to Clang's diagnostics
133^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134- ``-Wliteral-range`` will warn on floating-point equality comparisons with
135  constants that are not representable in a casted value. For example,
136  ``(float) f == 0.1`` is always false.
137- ``-Winline-namespace-reopened-noninline`` now takes into account that the
138  ``inline`` keyword must appear on the original but not necessarily all
139  extension definitions of an inline namespace and therefore points its note
140  at the original definition. This fixes `Issue 50794 (PR51452)
141  <https://github.com/llvm/llvm-project/issues/50794>`_.
142- ``-Wunused-but-set-variable`` now also warns if the variable is only used
143  by unary operators.
144- ``-Wunused-variable`` no longer warn for references extending the lifetime
145  of temporaries with side effects. This fixes `Issue 54489
146  <https://github.com/llvm/llvm-project/issues/54489>`_.
147- Modified the behavior of ``-Wstrict-prototypes`` and added a new, related
148  diagnostic ``-Wdeprecated-non-prototype``. The strict prototypes warning will
149  now only diagnose deprecated declarations and definitions of functions
150  without a prototype where the behavior in C2x will remain correct. This
151  diagnostic remains off by default but is now enabled via ``-pedantic`` due to
152  it being a deprecation warning. ``-Wdeprecated-non-prototype`` will diagnose
153  cases where the deprecated declarations or definitions of a function without
154  a prototype will change behavior in C2x. Additionally, it will diagnose calls
155  which pass arguments to a function without a prototype. This warning is
156  enabled only when the ``-Wdeprecated-non-prototype`` option is enabled at the
157  function declaration site, which allows a developer to disable the diagnostic
158  for all callers at the point of declaration. This diagnostic is grouped under
159  the ``-Wstrict-prototypes`` warning group, but is enabled by default.
160- Clang now appropriately issues an error in C when a definition of a function
161  without a prototype and with no arguments is an invalid redeclaration of a
162  function with a prototype. e.g., ``void f(int); void f() {}`` is now properly
163  diagnosed.
164- The ``-Wimplicit-function-declaration`` warning diagnostic now defaults to
165  an error in C99 and later. Prior to C2x, it may be downgraded to a warning
166  with ``-Wno-error=implicit-function-declaration``, or disabled entirely with
167  ``-Wno-implicit-function-declaration``. As of C2x, support for implicit
168  function declarations has been removed, and the warning options will have no
169  effect.
170
171- ``-Wmisexpect`` warns when the branch weights collected during profiling
172  conflict with those added by ``llvm.expect``.
173
174Non-comprehensive list of changes in this release
175-------------------------------------------------
176- Improve __builtin_dump_struct:
177  - Support bitfields in struct and union.
178  - Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
179  - Remove anonymous tag locations.
180  - Beautify dump format, add indent for nested struct and struct members.
181- Previously disabled sanitizer options now enabled by default:
182  - ASAN_OPTIONS=detect_stack_use_after_return=1 (except Windows).
183  - MSAN_OPTIONS=poison_in_dtor=1.
184
185New Compiler Flags
186------------------
187- Added the ``-fno-knr-functions`` flag to allow users to opt into the C2x
188  behavior where a function with an empty parameter list is treated as though
189  the parameter list were ``void``. There is no ``-fknr-functions`` or
190  ``-fno-no-knr-functions`` flag; this feature cannot be disabled in language
191  modes where it is required, such as C++ or C2x.
192
193Deprecated Compiler Flags
194-------------------------
195
196Modified Compiler Flags
197-----------------------
198
199Removed Compiler Flags
200-------------------------
201
202New Pragmas in Clang
203--------------------
204
205- ...
206
207Attribute Changes in Clang
208--------------------------
209
210- Added support for parameter pack expansion in `clang::annotate`.
211
212- The ``overloadable`` attribute can now be written in all of the syntactic
213  locations a declaration attribute may appear.
214  This fixes `Issue 53805 <https://github.com/llvm/llvm-project/issues/53805>`_.
215
216- Improved namespace attributes handling:
217
218  - Handle GNU attributes before a namespace identifier and subsequent
219    attributes of different kinds.
220  - Emit error on GNU attributes for a nested namespace definition.
221
222- Statement attributes ``[[clang::noinline]]`` and  ``[[clang::always_inline]]``
223  can be used to control inlining decisions at callsites.
224
225- ``#pragma clang attribute push`` now supports multiple attributes within a single directive.
226
227- The ``__declspec(naked)`` attribute can no longer be written on a member
228  function in Microsoft compatibility mode, matching the behavior of cl.exe.
229
230Windows Support
231---------------
232
233- Add support for MSVC-compatible ``/JMC``/``/JMC-`` flag in clang-cl (supports
234  X86/X64/ARM/ARM64). ``/JMC`` could only be used when ``/Zi`` or ``/Z7`` is
235  turned on. With this addition, clang-cl can be used in Visual Studio for the
236  JustMyCode feature. Note, you may need to manually add ``/JMC`` as additional
237  compile options in the Visual Studio since it currently assumes clang-cl does not support ``/JMC``.
238
239C Language Changes in Clang
240---------------------------
241
242C2x Feature Support
243-------------------
244
245- Implemented `WG14 N2674 The noreturn attribute <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf>`_.
246- Implemented `WG14 N2935 Make false and true first-class language features <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2935.pdf>`_.
247- Implemented `WG14 N2763 Adding a fundamental type for N-bit integers <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf>`_.
248- Implemented `WG14 N2775 Literal suffixes for bit-precise integers <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf>`_.
249- Implemented the `*_WIDTH` macros to complete support for
250  `WG14 N2412 Two's complement sign representation for C2x <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf>`_.
251- Implemented `WG14 N2418 Adding the u8 character prefix <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2418.pdf>`_.
252- Removed support for implicit function declarations. This was a C89 feature
253  that was removed in C99, but cannot be supported in C2x because it requires
254  support for functions without prototypes, which no longer exist in C2x.
255- Implemented `WG14 N2841 No function declarators without prototypes <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm>`_
256  and `WG14 N2432 Remove support for function definitions with identifier lists <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf>`_.
257
258C++ Language Changes in Clang
259-----------------------------
260
261- Improved ``-O0`` code generation for calls to ``std::move``, ``std::forward``,
262  ``std::move_if_noexcept``, ``std::addressof``, and ``std::as_const``. These
263  are now treated as compiler builtins and implemented directly, rather than
264  instantiating the definition from the standard library.
265
266C++20 Feature Support
267^^^^^^^^^^^^^^^^^^^^^
268- Diagnose consteval and constexpr issues that happen at namespace scope. This
269  partially addresses `Issue 51593 <https://github.com/llvm/llvm-project/issues/51593>`_.
270- No longer attempt to evaluate a consteval UDL function call at runtime when
271  it is called through a template instantiation. This fixes
272  `Issue 54578 <https://github.com/llvm/llvm-project/issues/54578>`_.
273
274- Implemented `__builtin_source_location()` which enables library support for std::source_location.
275
276- The mangling scheme for C++20 modules has incompatibly changed. The
277  initial mangling was discovered not to be reversible, and the weak
278  ownership design decision did not give the backwards compatibility
279  that was hoped for. C++20 since added ``extern "C++"`` semantics
280  that can be used for such compatibility. The demangler now demangles
281  symbols with named module attachment.
282
283C++2b Feature Support
284^^^^^^^^^^^^^^^^^^^^^
285
286- Implemented `P2128R6: Multidimensional subscript operator <https://wg21.link/P2128R6>`_.
287- Implemented `P0849R8: auto(x): decay-copy in the language <https://wg21.link/P0849R8>`_.
288- Implemented `P2242R3: Non-literal variables (and labels and gotos) in constexpr functions	<https://wg21.link/P2242R3>`_.
289
290CUDA Language Changes in Clang
291------------------------------
292
293Objective-C Language Changes in Clang
294-------------------------------------
295
296OpenCL C Language Changes in Clang
297----------------------------------
298
299...
300
301ABI Changes in Clang
302--------------------
303
304OpenMP Support in Clang
305-----------------------
306
307...
308
309CUDA Support in Clang
310---------------------
311
312- ...
313
314X86 Support in Clang
315--------------------
316
317DWARF Support in Clang
318----------------------
319
320Arm and AArch64 Support in Clang
321--------------------------------
322
323Floating Point Support in Clang
324-------------------------------
325
326Internal API Changes
327--------------------
328
329- Added a new attribute flag `AcceptsExprPack` that when set allows expression
330  pack expansions in the parsed arguments of the corresponding attribute.
331  Additionally it introduces delaying of attribute arguments, adding common
332  handling for creating attributes that cannot be fully initialized prior to
333  template instantiation.
334
335Build System Changes
336--------------------
337
338* CMake ``-DCLANG_DEFAULT_PIE_ON_LINUX=ON`` is now the default. This is used by
339  linux-gnu systems to decide whether ``-fPIE -pie`` is the default (instead of
340  ``-fno-pic -no-pie``). This matches GCC installations on many Linux distros.
341  Note: linux-android and linux-musl always default to ``-fPIE -pie``, ignoring
342  this variable. ``-DCLANG_DEFAULT_PIE_ON_LINUX`` may be removed in the future.
343
344AST Matchers
345------------
346
347- Expanded ``isInline`` narrowing matcher to support c++17 inline variables.
348
349clang-format
350------------
351
352- **Important change**: Renamed ``IndentRequires`` to ``IndentRequiresClause``
353  and changed the default for all styles from ``false`` to ``true``.
354
355- Reworked and improved handling of concepts and requires. Added the
356  ``RequiresClausePosition`` option as part of that.
357
358- Changed ``BreakBeforeConceptDeclarations`` from ``Boolean`` to an enum.
359
360- Option ``InsertBraces`` has been added to insert optional braces after control
361  statements.
362
363libclang
364--------
365
366- ...
367
368Static Analyzer
369---------------
370
371- ...
372
373.. _release-notes-ubsan:
374
375Undefined Behavior Sanitizer (UBSan)
376------------------------------------
377
378Core Analysis Improvements
379==========================
380
381- ...
382
383New Issues Found
384================
385
386- ...
387
388Python Binding Changes
389----------------------
390
391The following methods have been added:
392
393-  ...
394
395Significant Known Problems
396==========================
397
398Additional Information
399======================
400
401A wide variety of additional information is available on the `Clang web
402page <https://clang.llvm.org/>`_. The web page contains versions of the
403API documentation which are up-to-date with the Git version of
404the source code. You can access versions of these documents specific to
405this release by going into the "``clang/docs/``" directory in the Clang
406tree.
407
408If you have any questions or comments about Clang, please feel free to
409contact us via the `mailing
410list <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_.
411