1========================================
2Clang 13.0.0 Release Notes
3========================================
4
5.. contents::
6   :local:
7   :depth: 2
8
9Written by the `LLVM Team <https://llvm.org/>`_
10
11Introduction
12============
13
14This document contains the release notes for the Clang C/C++/Objective-C
15frontend, part of the LLVM Compiler Infrastructure, release 13.0.0. Here we
16describe the status of Clang in some detail, including major
17improvements from the previous release and new feature work. For the
18general LLVM release notes, see `the LLVM
19documentation <https://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
20releases may be downloaded from the `LLVM releases web
21site <https://llvm.org/releases/>`_.
22
23For more information about Clang or LLVM, including information about the
24latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
25`LLVM Web Site <https://llvm.org>`_.
26
27Note that if you are reading this file from a Git checkout or the
28main Clang web page, this document applies to the *next* release, not
29the current one. To see the release notes for a specific release, please
30see the `releases page <https://llvm.org/releases/>`_.
31
32What's New in Clang 13.0.0?
33===========================
34
35Some of the major new features and improvements to Clang are listed
36here. Generic improvements to Clang as a whole or to its underlying
37infrastructure are described first, followed by language-specific
38sections with improvements to Clang's support for those languages.
39
40Major New Features
41------------------
42
43- Guaranteed tail calls are now supported with statement attributes
44  ``[[clang::musttail]]`` in C++ and ``__attribute__((musttail))`` in C. The
45  attribute is applied to a return statement (not a function declaration),
46  and an error is emitted if a tail call cannot be guaranteed, for example if
47  the function signatures of caller and callee are not compatible. Guaranteed
48  tail calls enable a class of algorithms that would otherwise use an
49  arbitrary amount of stack space.
50
51Improvements to Clang's diagnostics
52^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53
54- ...
55
56Non-comprehensive list of changes in this release
57-------------------------------------------------
58
59- The default value of _MSC_VER was raised from 1911 to 1914. MSVC 19.14 has the
60  support to overaligned objects on x86_32 which is required for some LLVM
61  passes.
62
63New Compiler Flags
64------------------
65
66- ``-Wreserved-identifier`` emits warning when user code uses reserved
67  identifiers.
68
69- ``Wunused-but-set-parameter`` and ``-Wunused-but-set-variable`` emit warnings
70  when a parameter or a variable is set but not used.
71
72- ``-fstack-usage`` generates an extra .su file per input source file. The .su
73  file contains frame size information for each function defined in the source
74  file.
75
76- ``-Wnull-pointer-subtraction`` emits warning when user code may have
77  undefined behaviour due to subtraction involving a null pointer.
78
79Deprecated Compiler Flags
80-------------------------
81
82- ...
83
84Modified Compiler Flags
85-----------------------
86
87- -Wshadow now also checks for shadowed structured bindings
88- ``-B <prefix>`` (when ``<prefix>`` is a directory) was overloaded to additionally
89  detect GCC installations under ``<prefix>`` (``lib{,32,64}/gcc{,-cross}/$triple``).
90  This behavior was incompatible with GCC, caused interop issues with
91  ``--gcc-toolchain``, and was thus dropped. Specify ``--gcc-toolchain=<dir>``
92  instead. ``-B``'s other GCC-compatible semantics are preserved:
93  ``$prefix/$triple-$file`` and ``$prefix$file`` are searched for executables,
94  libraries, includes, and data files used by the compiler.
95- ``-Wextra`` now also implies ``-Wnull-pointer-subtraction.``
96
97Removed Compiler Flags
98-------------------------
99
100- The clang-cl ``/fallback`` flag, which made clang-cl invoke Microsoft Visual
101  C++ on files it couldn't compile itself, has been removed.
102
103- ``-Wreturn-std-move-in-c++11``, which checked whether an entity is affected by
104  `CWG1579 <https://wg21.link/CWG1579>`_ to become implicitly movable, has been
105  removed.
106
107New Pragmas in Clang
108--------------------
109
110- ...
111
112Attribute Changes in Clang
113--------------------------
114
115- ...
116
117- Added support for C++11-style ``[[]]`` attributes on using-declarations, as a
118  clang extension.
119
120Windows Support
121---------------
122
123- Fixed reading ``long double`` arguments with ``va_arg`` on x86_64 MinGW
124  targets.
125
126C Language Changes in Clang
127---------------------------
128
129- ...
130
131C++ Language Changes in Clang
132-----------------------------
133
134- The oldest supported GNU libstdc++ is now 4.8.3 (released 2014-05-22).
135  Clang workarounds for bugs in earlier versions have been removed.
136
137- ...
138
139C++20 Feature Support
140^^^^^^^^^^^^^^^^^^^^^
141...
142
143C++2b Feature Support
144^^^^^^^^^^^^^^^^^^^^^
145...
146
147Objective-C Language Changes in Clang
148-------------------------------------
149
150OpenCL Kernel Language Changes in Clang
151---------------------------------------
152
153
154Command-line interface changes:
155
156- All builtin types, macros and function declarations are now added by default
157  without any command-line flags. A flag is provided ``-cl-no-stdinc`` to
158  suppress the default declarations non-native to the compiler.
159
160- Clang now compiles using OpenCL C version 1.2 by default if no version is
161  specified explicitly from the command line.
162
163- Clang now supports ``.clcpp`` file extension for sources written in
164  C++ for OpenCL.
165
166- Clang now accepts ``-cl-std=clc++1.0`` that sets C++ for OpenCL to
167  the version 1.0 explicitly.
168
169Misc common changes:
170
171- Added ``NULL`` definition in internal headers for standards prior to the
172  version 2.0.
173
174- Simplified use of pragma in extensions for ``double``, images, atomics,
175  subgroups, Arm dot product extension. There are less cases where extension
176  pragma is now required by clang to compile kernel sources.
177
178- Added missing ``as_size``/``as_ptrdiff``/``as_intptr``/``as_uintptr_t``
179  operators to internal headers.
180
181- Added new builtin function for ndrange, ``cl_khr_subgroup_extended_types``,
182  ``cl_khr_subgroup_non_uniform_vote``, ``cl_khr_subgroup_ballot``,
183  ``cl_khr_subgroup_non_uniform_arithmetic``, ``cl_khr_subgroup_shuffle``,
184  ``cl_khr_subgroup_shuffle_relative``, ``cl_khr_subgroup_clustered_reduce``
185  into the default Tablegen-based header.
186
187- Added online documentation for Tablegen-based header, OpenCL 3.0 support,
188  new clang extensions.
189
190- Fixed OpenCL C language version and SPIR address space reporting in DWARF.
191
192New extensions:
193
194- ``cl_khr_integer_dot_product`` for dedicated support of dot product.
195
196- ``cl_khr_extended_bit_ops`` for dedicated support of extra binary operations.
197
198- ``__cl_clang_bitfields`` for use of bit-fields in the kernel code.
199
200- ``__cl_clang_non_portable_kernel_param_types`` for relaxing some restrictions
201  to types of kernel parameters.
202
203OpenCL C 3.0 related changes:
204
205- Added parsing support for the optionality of generic address space, images
206  (including 3d writes and ``read_write`` access qualifier), pipes, program
207  scope variables, double-precision floating-point support.
208
209- Added optionality support for builtin functions (in ``opencl-c.h`` header)
210  for generic address space, C11 atomics.
211
212- Added ``memory_scope_all_devices`` enum for the atomics in internal headers.
213
214- Enabled use of ``.rgba`` vector components.
215
216C++ for OpenCL related changes:
217
218- Added ``__remove_address_space`` metaprogramming utility in internal headers
219  to allow removing address spaces from types.
220
221- Improved overloads resolution logic for constructors wrt address spaces.
222
223- Improved diagnostics of OpenCL specific types and address space qualified
224  types in ``reinterpret_cast`` and template functions.
225
226- Fixed ``NULL`` macro in internal headers to be compatible with C++.
227
228- Fixed use of ``half`` type.
229
230ABI Changes in Clang
231--------------------
232
233OpenMP Support in Clang
234-----------------------
235
236- Support for loop transformation directives from OpenMP 5.1 have been added.
237  ``#pragma omp unroll`` is a standardized alternative to ``#pragma unroll``
238  (or ``#pragma clang loop unroll(enable)``) but also allows composition with
239  other OpenMP loop associated constructs as in
240
241  .. code-block:: c
242
243    #pragma omp parallel for
244    #pragma omp unroll partial(4)
245    for (int i = 0; i < n; ++i)
246
247  ``#pragma omp tile`` applies tiling to a perfect loop nest using a
248  user-defined tile size.
249
250  .. code-block:: c
251
252    #pragma omp tile sizes(8,8)
253    for (int i = 0; i < m; ++i)
254      for (int j = 0; j < n; ++j)
255
256- ...
257
258CUDA Support in Clang
259---------------------
260
261- ...
262
263X86 Support in Clang
264--------------------
265
266- ...
267
268Internal API Changes
269--------------------
270
271These are major API changes that have happened since the 12.0.0 release of
272Clang. If upgrading an external codebase that uses Clang as a library,
273this section should help get you past the largest hurdles of upgrading.
274
275- ...
276
277Build System Changes
278--------------------
279
280These are major changes to the build system that have happened since the 12.0.0
281release of Clang. Users of the build system should adjust accordingly.
282
283- The option ``LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA`` no longer exists. There were
284  two releases with that flag forced off, and no uses were added that forced it
285  on. The recommended replacement is clangd.
286
287- ...
288
289AST Matchers
290------------
291
292- ...
293
294clang-format
295------------
296
297- Option ``SpacesInLineCommentPrefix`` has been added to control the
298  number of spaces in a line comments prefix.
299
300- Option ``SortIncludes`` has been updated from a ``bool`` to an
301  ``enum`` with backwards compatibility. In addition to the previous
302  ``true``/``false`` states (now ``CaseSensitive``/``Never``), a third
303  state has been added (``CaseInsensitive``) which causes an alphabetical sort
304  with case used as a tie-breaker.
305
306  .. code-block:: c++
307
308    // Never (previously false)
309    #include "B/A.h"
310    #include "A/B.h"
311    #include "a/b.h"
312    #include "A/b.h"
313    #include "B/a.h"
314
315    // CaseSensitive (previously true)
316    #include "A/B.h"
317    #include "A/b.h"
318    #include "B/A.h"
319    #include "B/a.h"
320    #include "a/b.h"
321
322    // CaseInsensitive
323    #include "A/B.h"
324    #include "A/b.h"
325    #include "a/b.h"
326    #include "B/A.h"
327    #include "B/a.h"
328
329- ``BasedOnStyle: InheritParentConfig`` allows to use the ``.clang-format`` of
330  the parent directories to overwrite only parts of it.
331
332- Option ``IndentAccessModifiers`` has been added to be able to give access
333  modifiers their own indentation level inside records.
334
335- Option ``PPIndentWidth`` has been added to be able to configure pre-processor
336  indentation independent from regular code.
337
338- Option ``ShortNamespaceLines`` has been added to give better control
339  over ``FixNamespaceComments`` when determining a namespace length.
340
341- Support for Whitesmiths has been improved, with fixes for ``namespace`` blocks
342  and ``case`` blocks and labels.
343
344- Option ``EmptyLineAfterAccessModifier`` has been added to remove, force or keep
345  new lines after access modifiers.
346
347- Checks for newlines in option ``EmptyLineBeforeAccessModifier`` are now based
348  on the formatted new lines and not on the new lines in the file. (Fixes
349  https://llvm.org/PR41870.)
350
351- Option ``SpacesInAngles`` has been improved, it now accepts ``Leave`` value
352  that allows to keep spaces where they are already present.
353
354- Option ``AllowShortIfStatementsOnASingleLine`` has been improved, it now
355  accepts ``AllIfsAndElse`` value that allows to put "else if" and "else" short
356  statements on a single line. (Fixes https://llvm.org/PR50019.)
357
358- Option ``BreakInheritanceList`` gets a new style, ``AfterComma``. It breaks
359  only after the commas that separate the base-specifiers.
360
361- Option ``LambdaBodyIndentation`` has been added to control how the body of a
362  lambda is indented. The default ``Signature`` value indents the body one level
363  relative to whatever indentation the signature has. ``OuterScope`` lets you
364  change that so that the lambda body is indented one level relative to the scope
365  containing the lambda, regardless of where the lambda signature was placed.
366
367- Option ``IfMacros`` has been added. This lets you define macros that get
368  formatted like conditionals much like ``ForEachMacros`` get styled like
369  foreach loops.
370
371- ``git-clang-format`` no longer formats changes to symbolic links. (Fixes
372  https://llvm.org/PR46992.)
373
374- Makes ``PointerAligment: Right`` working with ``AlignConsecutiveDeclarations``.
375  (Fixes https://llvm.org/PR27353)
376
377- Option ``AlignArrayOfStructure`` has been added to allow for ordering array-like
378  initializers.
379
380- Support for formatting JSON file (\*.json) has been added to clang-format.
381
382libclang
383--------
384
385- Make libclang SONAME independent from LLVM version. It will be updated only when
386  needed. Defined in CLANG_SONAME (clang/tools/libclang/CMakeLists.txt).
387  `More details <https://lists.llvm.org/pipermail/cfe-dev/2021-June/068423.html>`_
388
389Static Analyzer
390---------------
391
392.. 2407eb08a574 [analyzer] Update static analyzer to be support sarif-html
393
394- Add a new analyzer output type, ``sarif-html``, that outputs both HTML and
395  Sarif files.
396
397.. 90377308de6c [analyzer] Support allocClassWithName in OSObjectCStyleCast checker
398
399- Add support for ``allocClassWithName`` in OSObjectCStyleCast checker.
400
401.. cad9b7f708e2b2d19d7890494980c5e427d6d4ea: Print time taken to analyze each function
402
403- The option ``-analyzer-display-progress`` now also outputs analysis time for
404  each function.
405
406.. 9e02f58780ab8734e5d27a0138bd477d18ae64a1 [analyzer] Highlight arrows for currently selected event
407
408- For bug reports in HTML format, arrows are now highlighted for the currently
409  selected event.
410
411.. Deep Majumder's GSoC'21
412.. 80068ca6232b [analyzer] Fix for faulty namespace test in SmartPtrModelling
413.. d825309352b4 [analyzer] Handle std::make_unique
414.. 0cd98bef1b6f [analyzer] Handle std::swap for std::unique_ptr
415.. 13fe78212fe7 [analyzer] Handle << operator for std::unique_ptr
416.. 48688257c52d [analyzer] Model comparision methods of std::unique_ptr
417.. f8d3f47e1fd0 [analyzer] Updated comments to reflect D85817
418.. 21daada95079 [analyzer] Fix static_cast on pointer-to-member handling
419
420- While still in alpha, ``alpha.cplusplus.SmartPtr`` received numerous
421  improvements and nears production quality.
422
423.. 21daada95079 [analyzer] Fix static_cast on pointer-to-member handling
424.. 170c67d5b8cc [analyzer] Use the MacroExpansionContext for macro expansions in plists
425.. 02b51e5316cd [analyzer][solver] Redesign constraint ranges data structure
426.. 3085bda2b348 [analyzer][solver] Fix infeasible constraints (PR49642)
427.. 015c39882ebc [Analyzer] Infer 0 value when the divisible is 0 (bug fix)
428.. 90377308de6c [analyzer] Support allocClassWithName in OSObjectCStyleCast checker
429.. df64f471d1e2 [analyzer] DynamicSize: Store the dynamic size
430.. e273918038a7 [analyzer] Track leaking object through stores
431.. 61ae2db2d7a9 [analyzer] Adjust the reported variable name in retain count checker
432.. 50f17e9d3139 [analyzer] RetainCountChecker: Disable reference counting for OSMetaClass.
433
434- Various fixes and improvements, including modeling of casts (such as
435  ``std::bit_cast<>``), constraint solving, explaining bug-causing variable
436  values, macro expansion notes, modeling the size of dynamic objects and the
437  modeling and reporting of Objective C/C++ retain count related bugs. These
438  should reduce false positives and make the remaining reports more readable.
439
440.. _release-notes-ubsan:
441
442Undefined Behavior Sanitizer (UBSan)
443------------------------------------
444
445Core Analysis Improvements
446==========================
447
448- ...
449
450New Issues Found
451================
452
453- ...
454
455Python Binding Changes
456----------------------
457
458The following methods have been added:
459
460-  ...
461
462Significant Known Problems
463==========================
464
465Additional Information
466======================
467
468A wide variety of additional information is available on the `Clang web
469page <https://clang.llvm.org/>`_. The web page contains versions of the
470API documentation which are up-to-date with the Git version of
471the source code. You can access versions of these documents specific to
472this release by going into the "``clang/docs/``" directory in the Clang
473tree.
474
475If you have any questions or comments about Clang, please feel free to
476contact us via the `mailing
477list <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_.
478