================ @@ -125,200 +219,439 @@ Resolutions to C++ Defect Reports C Language Changes ------------------ +- Implemented the ``defer`` draft Technical Specification + (`WG14 N3734 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3734.pdf>`_); it is enabled in C mode by + passing ``-fdefer-ts``. Note, the details of this feature are subject to change given that the Technical + Specification is not yet ratified. + C2y Feature Support ^^^^^^^^^^^^^^^^^^^ +- No longer triggering ``-Wstatic-in-inline`` in C2y mode; use of a static + function or variable within an extern inline function is no longer a + constraint per `WG14 N3622 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt>`_. +- Clang now supports `N3355 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm>`_ Named Loops. +- Clang's implementation of ``__COUNTER__`` was updated to conform to + `WG14 N3457 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm>`_. + This includes adding pedantic warnings for the feature being an extension in + other language modes as well as an error when the counter is expanded more + than 2147483647 times. C23 Feature Support ^^^^^^^^^^^^^^^^^^^ +- Added ``FLT_SNAN``, ``DBL_SNAN``, and ``LDBL_SNAN`` to Clang's ``<float.h>`` + header in C23 and later modes. This implements + `WG14 N2710 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2710.htm>`_. +- Fixed accepting as compatible unnamed tag types with the same fields within + the same translation unit but from different types. +- ``-MG`` now silences the "file not found" errors with ``#embed`` when + scanning for dependencies and encountering an unknown file. #GH165632 Non-comprehensive list of changes in this release ------------------------------------------------- +- Added ``__scoped_atomic_uinc_wrap`` and ``__scoped_atomic_udec_wrap``. + +- Removed OpenCL header-only feature macros (previously unconditionally enabled + on SPIR-V and only selectively disabled via ``-D__undef_<feature>``). All + OpenCL extensions and features are now centralized in OpenCLExtensions.def, + allowing consistent control via ``getSupportedOpenCLOpts`` and ``-cl-ext``. + +- Added ``__builtin_elementwise_ldexp``. + +- Added ``__builtin_elementwise_fshl`` and ``__builtin_elementwise_fshr``. + +- ``__builtin_elementwise_abs`` can now be used in constant expression. + +- Added ``__builtin_elementwise_minnumnum`` and ``__builtin_elementwise_maxnumnum``. + +- Trapping UBSan (e.g. ``-fsanitize=undefined -fsanitize-trap=undefined``) now + emits a string describing the reason for trapping into the generated debug + info. This feature allows debuggers (e.g. LLDB) to display the reason for + trapping if the trap is reached. The string is currently encoded in the debug + info as an artificial frame that claims to be inlined at the trap location. + The function used for the artificial frame is an artificial function whose + name encodes the reason for trapping. The encoding used is currently the same + as ``__builtin_verbose_trap`` but might change in the future. This feature is + enabled by default but can be disabled by compiling with + ``-fno-sanitize-debug-trap-reasons``. The feature has a ``basic`` and + ``detailed`` mode (the default). The ``basic`` mode emits a hard-coded string + per trap kind (e.g. ``Integer addition overflowed``) and the ``detailed`` mode + emits a more descriptive string describing each individual trap (e.g. ``signed + integer addition overflow in 'a + b'``). The ``detailed`` mode produces larger + debug info than ``basic`` but is more helpful for debugging. The + ``-fsanitize-debug-trap-reasons=`` flag can be used to switch between the + different modes or disable the feature entirely. Note due to trap merging in + optimized builds (i.e. in each function all traps of the same kind get merged + into the same trap instruction) the trap reasons might be removed. To prevent + this build without optimizations (i.e. use `-O0` or use the `optnone` function + attribute) or use the `fno-sanitize-merge=` flag in optimized builds. + +- ``__builtin_elementwise_max`` and ``__builtin_elementwise_min`` functions for integer types can + now be used in constant expressions. + +- A vector of booleans is now a valid condition for the ternary ``?:`` operator. + This binds to a simple vector select operation. + +- Added ``__builtin_masked_load``, ``__builtin_masked_expand_load``, + ``__builtin_masked_store``, ``__builtin_masked_compress_store`` for + conditional memory loads from vectors. Binds to the LLVM intrinsics of the + same name. + +- Added ``__builtin_masked_gather`` and ``__builtin_masked_scatter`` for + conditional gathering and scattering operations on vectors. Binds to the LLVM + intrinsics of the same name. + +- The ``__builtin_popcountg``, ``__builtin_ctzg``, and ``__builtin_clzg`` + functions now accept fixed-size boolean vectors. + +- Use of ``__has_feature`` to detect the ``ptrauth_qualifier`` and ``ptrauth_intrinsics`` + features has been deprecated, and is restricted to the arm64e target only. The + correct method to check for these features is to test for the ``__PTRAUTH__`` + macro. + +- Added a new builtin, ``__builtin_dedup_pack``, to remove duplicate types from a parameter pack. + This feature is particularly useful in template metaprogramming for normalizing type lists. + The builtin produces a new, unexpanded parameter pack that can be used in contexts like template + argument lists or base specifiers. -- Added ``__builtin_stdc_rotate_left`` and ``__builtin_stdc_rotate_right`` - for bit rotation of unsigned integers including ``_BitInt`` types. Rotation - counts are normalized modulo the bit-width and support negative values. - Usable in constant expressions. Implicit conversion is supported for - class/struct types with conversion operators. + .. code-block:: c++ -- A new generic bit-reverse builtin function ``__builtin_bitreverseg`` that - extends bit-reversal support to all standard integers type, including - ``_BitInt`` + template <typename...> struct TypeList; + + // The resulting type is TypeList<int, double, char> + using MyTypeList = TypeList<__builtin_dedup_pack<int, double, int, char, double>...>; + + Currently, the use of ``__builtin_dedup_pack`` is limited to template arguments and base + specifiers, it also must be used within a template context. + +- ``__builtin_assume_dereferenceable`` now accepts non-constant size operands. + +- Fixed a crash when the second argument to ``__builtin_assume_aligned`` was not constant (#GH161314) + +- Introduce support for :doc:`allocation tokens <AllocToken>` to enable + allocator-level heap organization strategies. A feature to instrument all + allocation functions with a token ID can be enabled via the + ``-fsanitize=alloc-token`` flag. + +- A new generic byte swap builtin function ``__builtin_bswapg`` that extends the existing + __builtin_bswap{16,32,64} function family to support all standard integer types. + +- A builtin ``__builtin_infer_alloc_token(<args>, ...)`` is provided to allow + compile-time querying of allocation token IDs, where the builtin arguments + mirror those normally passed to an allocation function. + +- Clang now rejects the invalid use of ``constexpr`` with ``auto`` and an explicit type in C. (#GH163090) New Compiler Flags ------------------ -- New option ``-fms-anonymous-structs`` / ``-fno-ms-anonymous-structs`` added - to enable or disable Microsoft's anonymous struct/union extension without - enabling other ``-fms-extensions`` features (#GH177607). -- New option ``--precompile-reduced-bmi`` allows build system to generate a - reduced BMI only for a C++20 importable module unit. Previously the users - can only generate the reduced BMI as a by-product, e.g, an object files or - a full BMI. - -- New ``-cc1`` option ``-fexperimental-overflow-behavior-types`` added to - enable parsing of the experimental ``overflow_behavior`` type attribute and - type specifiers. +- New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``). +- New option ``-fsanitize-debug-trap-reasons=`` added to control emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``). +- New options for enabling allocation token instrumentation: ``-fsanitize=alloc-token``, ``-falloc-token-max=``, ``-fsanitize-alloc-token-fast-abi``, ``-fsanitize-alloc-token-extended``. +- The ``-resource-dir`` option is now displayed in the list of options shown by ``--help``. +- New option ``-fmatrix-memory-layout`` added to control the memory layout of Clang matrix types. (e.g. ``-fmatrix-memory-layout=column-major`` or ``-fmatrix-memory-layout=row-major``). + +Lanai Support +^^^^^^^^^^^^^^ +- The option ``-mcmodel={small,medium,large}`` is supported again. Deprecated Compiler Flags ------------------------- Modified Compiler Flags ----------------------- -- The `-mno-outline` and `-moutline` compiler flags are now allowed on RISC-V and X86, which both support the machine outliner. -- The `-mno-outline` flag will now add the `nooutline` IR attribute, so that - `-mno-outline` and `-moutline` objects can be mixed correctly during LTO. +- The `-gkey-instructions` compiler flag is now enabled by default when DWARF is emitted for plain C/C++ and optimizations are enabled. (#GH149509) +- The `-fconstexpr-steps` compiler flag now accepts value `0` to opt out of this limit. (#GH160440) +- The `-fdevirtualize-speculatively` compiler flag is now supported to enable speculative devirtualization of virtual function calls, it's disabled by default. (#GH159685) Removed Compiler Flags ----------------------- +------------------------- Attribute Changes in Clang -------------------------- +- The definition of a function declaration with ``[[clang::cfi_unchecked_callee]]`` inherits this + attribute, allowing the attribute to only be attached to the declaration. Prior, this would be + treated as an error where the definition and declaration would have differing types. -- Added new attribute ``stack_protector_ignore`` to opt specific local variables out of - the analysis which determines if a function should get a stack protector. A function - will still generate a stack protector if other local variables or command line flags - require it. - -- Added a new attribute, ``[[clang::no_outline]]`` to suppress outlining from - annotated functions. This uses the LLVM `nooutline` attribute. - -- Introduced a new type attribute ``__attribute__((overflow_behavior))`` which - currently accepts either ``wrap`` or ``trap`` as an argument, enabling - type-level control over overflow behavior. There is also an accompanying type - specifier for each behavior kind via `__ob_wrap` and `__ob_trap`. - -Improvements to Clang's diagnostics ------------------------------------ -- Added ``-Wlifetime-safety`` to enable lifetime safety analysis, - a CFG-based intra-procedural analysis that detects use-after-free and related - temporal safety bugs. See the - `RFC <https://discourse.llvm.org/t/rfc-intra-procedural-lifetime-analysis-in-clang/86291>`_ - for more details. By design, this warning is enabled in ``-Weverything``. To disable - the analysis, use ``-Wno-lifetime-safety`` or ``-fno-lifetime-safety``. - -- Added ``-Wlifetime-safety-suggestions`` to enable lifetime annotation suggestions. - This provides suggestions for function parameters that - should be marked ``[[clang::lifetimebound]]`` based on lifetime analysis. For - example, for the following function: - - .. code-block:: c++ - - int* p(int *in) { return in; } - - Clang will suggest: - - .. code-block:: c++ - - warning: parameter in intra-TU function should be marked [[clang::lifetimebound]] - int* p(int *in) { return in; } - ^~~~~~~ - [[clang::lifetimebound]] - note: param returned here - int* p(int *in) { return in; } - ^~ - -- Added ``-Wlifetime-safety-noescape`` to detect misuse of ``[[clang::noescape]]`` - annotation where the parameter escapes through return. For example: +- Instrumentation added by ``-fsanitize=function`` will also be omitted for indirect calls to function + pointers and function declarations marked with ``[[clang::cfi_unchecked_callee]]``. - .. code-block:: c++ - - int* p(int *in [[clang::noescape]]) { return in; } +- New format attributes ``gnu_printf``, ``gnu_scanf``, ``gnu_strftime`` and ``gnu_strfmon`` are added + as aliases for ``printf``, ``scanf``, ``strftime`` and ``strfmon``. (#GH16219) - Clang will warn: - - .. code-block:: c++ +- New function attribute `malloc_span` is added. It has semantics similar to that of the `malloc` + attribute, but `malloc_span` applies not to functions returning pointers, but to functions returning + span-like structures (i.e. those that contain a pointer field and a size integer field or two pointers). - warning: parameter is marked [[clang::noescape]] but escapes - int* p(int *in [[clang::noescape]]) { return in; } - ^~~~~~~ - note: returned here - int* p(int *in [[clang::noescape]]) { return in; } - ^~ - -- Added ``-Wlifetime-safety-dangling-field`` to detect dangling field references - when stack memory escapes to class fields. This is part of ``-Wlifetime-safety`` - and detects cases where local variables or parameters are stored in fields but - outlive their scope. For example: - - .. code-block:: c++ +- Added new attribute ``modular_format`` to allow dynamically selecting at link + time which aspects of a statically linked libc's printf (et al) + implementation are required. This can reduce code size without requiring e.g. + multilibs for printf features. Requires cooperation with the libc + implementation. - struct DanglingView { - std::string_view view; - DanglingView(std::string s) : view(s) {} // warning: address of stack memory escapes to a field - }; +- On targets with Itanium C++ ABI, Clang now supports ``[[gnu:gcc_struct]]`` + with the behavior similar to one existing in GCC. In particular, whenever + ``-mms-bitfields`` command line option is provided (or if Microsoft-compatible + structure layout is default on the target), ``[[gnu::gcc_struct]]`` requests + the compiler to follow Itanium rules for the layout of an annotated structure. -- Improved ``-Wassign-enum`` performance by caching enum enumerator values. (#GH176454) - -- Fixed a false negative in ``-Warray-bounds`` where the warning was suppressed - when accessing a member function on a past-the-end array element. - (#GH179128) - -- Added a missing space to the FixIt for the ``implicit-int`` group of diagnostics and - made sure that only one such diagnostic and FixIt is emitted per declaration group. (#GH179354) - -- The ``-Wloop-analysis`` warning has been extended to catch more cases of - variable modification inside lambda expressions (#GH132038). +Improvements to Clang's diagnostics +----------------------------------- +- Diagnostics messages now refer to ``structured binding`` instead of ``decomposition``, + to align with `P0615R0 <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0615r0.html>`_ changing the term. (#GH157880) +- Clang now suppresses runtime behavior warnings for unreachable code in file-scope + variable initializers, matching the behavior for functions. This prevents false + positives for operations in unreachable branches of constant expressions. +- Added a separate diagnostic group ``-Wfunction-effect-redeclarations``, for the more pedantic + diagnostics for function effects (``[[clang::nonblocking]]`` and ``[[clang::nonallocating]]``). + Moved the warning for a missing (though implied) attribute on a redeclaration into this group. + Added a new warning in this group for the case where the attribute is missing/implicit on + an override of a virtual method. +- Remove ``-Wperf-constraint-implies-noexcept`` from ``-Wall``. This warning is somewhat nit-picky and + attempts to resolve it, by adding ``noexcept``, can create new ways for programs to crash. (#GH167540) +- Implemented diagnostics when retrieving the tuple size for types where its specialization of `std::tuple_size` + produces an invalid size (either negative or greater than the implementation limit). (#GH159563) +- Fixed fix-it hint for fold expressions. Clang now correctly places the suggested right + parenthesis when diagnosing malformed fold expressions. (#GH151787) +- Added fix-it hint for when scoped enumerations require explicit conversions for binary operations. (#GH24265) +- Constant template parameters are now type checked in template definitions, + including template template parameters. +- Fixed an issue where emitted format-signedness diagnostics were not associated with an appropriate + diagnostic id. Besides being incorrect from an API standpoint, this was user visible, e.g.: + "format specifies type 'unsigned int' but the argument has type 'int' [-Wformat]" + "signedness of format specifier 'u' is incompatible with 'c' [-Wformat]" + This was misleading, because even though -Wformat is required in order to emit the diagnostics, + the warning flag the user needs to concerned with here is -Wformat-signedness, which is also + required and is not enabled by default. With the change you'll now see: + "format specifies type 'unsigned int' but the argument has type 'int', which differs in signedness [-Wformat-signedness]" + "signedness of format specifier 'u' is incompatible with 'c' [-Wformat-signedness]" + and the API-visible diagnostic id will be appropriate. +- Clang now produces better diagnostics for template template parameter matching + involving 'auto' template parameters. +- Fixed false positives in ``-Waddress-of-packed-member`` diagnostics when + potential misaligned members get processed before they can get discarded. + (#GH144729) +- Fix a false positive warning in ``-Wignored-qualifiers`` when the return type is undeduced. (#GH43054) + +- Clang now emits a diagnostic with the correct message in case of assigning to const reference captured in lambda. (#GH105647) + +- Fixed false positive in ``-Wmissing-noreturn`` diagnostic when it was requiring the usage of + ``[[noreturn]]`` on lambdas before C++23 (#GH154493). + +- Clang now diagnoses the use of ``#`` and ``##`` preprocessor tokens in + attribute argument lists in C++ when ``-pedantic`` is enabled. The operators + can be used in macro replacement lists with the usual preprocessor semantics, + however, non-preprocessor use of tokens now triggers a pedantic warning in C++. + Compilation in C mode is unchanged, and still permits these tokens to be used. (#GH147217) + +- Clang now diagnoses misplaced array bounds on declarators for template + specializations in th same way as it already did for other declarators. + (#GH147333) + +- A new warning ``-Walloc-size`` has been added to detect calls to functions + decorated with the ``alloc_size`` attribute don't allocate enough space for + the target pointer type. + +- The :doc:`ThreadSafetyAnalysis` attributes ``ACQUIRED_BEFORE(...)`` and + ``ACQUIRED_AFTER(...)`` have been moved to the stable feature set and no + longer require ``-Wthread-safety-beta`` to be used. +- The :doc:`ThreadSafetyAnalysis` gains basic alias-analysis of capability + pointers under ``-Wthread-safety-beta`` (still experimental), which reduces + both false positives but also false negatives through more precise analysis. + +- Clang now looks through parenthesis for ``-Wundefined-reinterpret-cast`` diagnostic. + +- Fixed a bug where the source location was missing when diagnosing ill-formed + placeholder constraints. + +- The two-element, unary mask variant of ``__builtin_shufflevector`` is now + properly being rejected when used at compile-time. It was not implemented + and caused assertion failures before (#GH158471). + +- Closed a loophole in the diagnosis of function pointer conversions changing + extended function type information in C mode (#GH41465). Function conversions + that were previously incorrectly accepted in case of other irrelevant + conditions are now consistently diagnosed, identical to C++ mode. + +- Fix false-positive unused label diagnostic when a label is used in a named break + or continue (#GH166013) +- Clang now emits a diagnostic in case `vector_size` or `ext_vector_type` + attributes are used with a negative size (#GH165463). +- Clang no longer emits ``-Wmissing-noreturn`` for virtual methods where + the function body consists of a `throw` expression (#GH167247). + +- A new warning ``-Wenum-compare-typo`` has been added to detect potential erroneous + comparison operators when mixed with bitwise operators in enum value initializers. + This can be locally disabled by explicitly casting the initializer value. +- Clang now provides correct caret placement when attributes appear before + `enum class` (#GH163224). + +- A new warning ``-Wshadow-header`` has been added to detect when a header file + is found in multiple search directories (excluding system paths). + +- Clang now detects potential missing format and format_matches attributes on function, + Objective-C method and block declarations when calling format functions. It is part + of the format-nonliteral diagnostic (#GH60718) + +- Fixed a crash when enabling ``-fdiagnostics-format=sarif`` and the output + carries messages like 'In file included from ...' or 'In module ...'. + Now the include/import locations are written into `sarif.run.result.relatedLocations`. + +- Clang now generates a fix-it for C++20 designated initializers when the + initializers do not match the declaration order in the structure. + +- Clang now doesn't throw assertion errors when comparing unsigned vectors(#173614) ---------------- Fznamznon wrote:
```suggestion - Clang now doesn't throw assertion errors when comparing unsigned vectors (#GH173614). ``` https://github.com/llvm/llvm-project/pull/182627 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
