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