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