Clang 23.0.0git (In-Progress) Release Notes

Written by the LLVM Team

Warning

These are in-progress notes for the upcoming Clang 23 release. Release notes for previous releases can be found on the Releases Page.

Introduction

This document contains the release notes for the Clang C/C++/Objective-C frontend, part of the LLVM Compiler Infrastructure, release 23.0.0git. Here we describe the status of Clang in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see the LLVM documentation. For the libc++ release notes, see this page. All LLVM releases may be downloaded from the LLVM releases web site.

For more information about Clang or LLVM, including information about the latest release, please see the Clang Web Site or the LLVM Web Site.

Potentially Breaking Changes

C/C++ Language Potentially Breaking Changes

C++ Specific Potentially Breaking Changes

  • Clang now more aggressively optimizes away stores to objects after they are dead. This behavior can be disabled with -fno-lifetime-dse.

  • Clang now correctly rejects export declarations in module implementation partitions. (#107602)

ABI Changes in This Version

  • Fixed incorrect struct layout for _BitInt bitfields wider than 255 bits on MSVC targets. Internal bitfield tracking fields were changed from unsigned char to uint64_t to prevent overflow. This might be an ABI break for such structs compared to earlier Clang versions.

AST Dumping Potentially Breaking Changes

  • The JSON AST dump now includes all fields from AvailabilityAttr: platform, introduced, deprecated, obsoleted, unavailable, message, strict, replacement, priority, and environment. Previously, these fields were missing from the JSON output.

Clang Frontend Potentially Breaking Changes

  • HIPSPV toolchain: –offload-targets=spirv{32,64} option is deprecated and will be removed when the new offload driver becomes default. The replacement for the option is –offload-targets=spirv{32,64}-unknown-chipstar when using the new offload driver (–offload-new-driver).

  • The new driver (–offload-new-driver) is now default for all offloading compilations. This changes the ABI for relocatable device code. Currently, libraries will need to be recompiled, or used with (–no-offload-new-driver). This option will be removed in the next release.

Clang Python Bindings Potentially Breaking Changes

  • Remove CompletionString.Availability. No libclang interfaces returned instances of it.

  • CompletionString.availability now returns instances of CompletionString.AvailabilityKindCompat.

    Instances of AvailabilityKindCompat have the same __str__ representation as the previous CompletionChunk.Kind and are equality-comparable with the existing AvailabilityKind enum. It will be replaced by AvailabilityKind in a future release. When this happens, the return type of CompletionString.availability will change to AvailabilityKind, so it is recommended to use AvailabilityKind to compare with the return values of CompletionString.availability.

  • Remove availabilityKinds. In this release, uses of availabilityKinds need to be replaced by CompletionString.AvailabilityKind.

  • CompletionChunk.kind now returns instances of CompletionChunkKind.

    Instances of CompletionChunkKind have the same __str__ representation as the previous CompletionChunk.Kind for compatibility. These representations will be changed in a future release to match other enums.

  • Remove completionChunkKindMap. In this release, uses of completionChunkKindMap need to be replaced by CompletionChunkKind.

  • Move SPELLING_CACHE into CompletionChunk and change it to use CompletionChunkKind instances as keys, instead of the enum values. An alias is kept in the form of a SPELLING_CACHE variable, but it only supports __getitem__ and __contains__. It will be removed in a future release. Please migrate to using CompletionChunk.SPELLING_CACHE instead.

  • SourceLocation and SourceRange now use NotImplemented to delegate equality checks (__eq__) to the other object they are compared with when they are of different classes. They previously returned False when compared with objects of other classes.

  • TranslationUnit.get_tokens now throws an error if both the extent and locations argument are passed. Previousy, locations took precedence.

  • _CXUnsavedFile will be renamed to UnsavedFile for consistency. UnsavedFile is already available to use and existing uses should be adapted to refer to it instead. _CXUnsavedFile will be removed in a future release.

What’s New in Clang 23.0.0git?

C++ Language Changes

  • __is_trivially_equality_comparable no longer returns false for all enum types. (#132672)

C++2c Feature Support

C++23 Feature Support

C++20 Feature Support

  • Clang now supports P1857R3 Modules Dependency Discovery. (#54047)

C++17 Feature Support

Resolutions to C++ Defect Reports

C Language Changes

C2y Feature Support

C23 Feature Support

  • Clang now allows C23 constexpr struct member access through the dot operator in constant expressions. (#178349)

Objective-C Language Changes

  • Clang now emits Objective-C number, array, and dictionary literals as compile-time constant data structures rather than runtime objc_msgSend calls on targets whose runtime supports constant literal classes. The feature can be disabled altogether with -fno-objc-constant-literals, or selectively per literal kind with -fno-constant-nsnumber-literals, -fno-constant-nsarray-literals, and -fno-constant-nsdictionary-literals.

Non-comprehensive list of changes in this release

  • Added support for floating point and pointer values in most __atomic_ builtins.

  • 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.

  • A new generic bit-reverse builtin function __builtin_bitreverseg that extends bit-reversal support to all standard integers type, including _BitInt

  • Deprecated float types support from __builtin_elementwise_max and __builtin_elementwise_min.

  • Added header endian.h which contains byte order helpers specified in POSIX

  • Added #pragma loop licm(disable) for llvm.loop.licm.disable metadata

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 (#177607).

  • 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 -cl option /d2guardnochecks added to match MSVC. When Windows Control Flow Guard (CFG) is enabled by other options, it will instruct Clang to emit the CFG metadata, but disable adding checks.

  • New option -fdiagnostics-show-inlining-chain added to show inlining chain notes for [[gnu::warning]] and [[gnu::error]] diagnostics. When a function with these attributes is called from an inlined context, Clang can now show which functions were inlined to reach the call. When debug info is available (-gline-directives-only (implicitly enabled at -g1) or higher), accurate source locations are used; otherwise, a heuristic fallback is used with a note suggesting how to enable debug info for better accuracy.

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.

Removed Compiler Flags

Attribute Changes in Clang

  • 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.

  • Introduced a new function attribute __attribute__((__personality__(...))) to explicitly specify the personality routine for exception handling. THis is meant to be a low level tool for language runtime authors to associate a foreign language personality with a given function. Note that this does not perform any ABI validation for the personality routine.

  • The Thread Safety Analysis attributes guarded_by and pt_guarded_by now accept multiple capability arguments with refined access semantics: writing requires all listed capabilities to be held exclusively, while reading requires at least one to be held. This is sound because any writer must hold all capabilities, so holding any one prevents concurrent writes.

Improvements to Clang’s diagnostics

  • -Wunused-but-set-variable now diagnoses file-scope variables with internal linkage (static storage class) that are assigned but never used. This new coverage is added under the subgroup -Wunused-but-set-global, allowing it to be disabled independently with -Wno-unused-but-set-global. (#148361)

  • 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 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:

    int* p(int *in) { return in; }
    

    Clang will suggest:

    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:

    int* p(int *in [[clang::noescape]]) { return in; }
    

    Clang will warn:

    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:

    struct DanglingView {
      std::string_view view;
      DanglingView(std::string s) : view(s) {}  // warning: address of stack memory escapes to a field
    };
    
  • Improved -Wassign-enum performance by caching enum enumerator values. (#176454)

  • Fixed a false negative in -Warray-bounds where the warning was suppressed when accessing a member function on a past-the-end array element. (#179128)

  • 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. (#179354)

  • Fixed the Fix-It insertion point for expected ';' after alias declaration when parsing alias declarations involving a token-split >> sequence (for example, using A = X<int>>;). (#184425)

  • Fixed incorrect implicitly deleted diagnostic for explicitly deleted candidate function. (#185693)

  • The -Wloop-analysis warning has been extended to catch more cases of variable modification inside lambda expressions (#132038).

  • Clang now emits -Wsizeof-pointer-memaccess when snprintf/vsnprintf use the sizeof the destination buffer(dynamically allocated) in the len parameter(#162366)

  • Added -Wmodule-map-path-outside-directory (off by default) to warn on header and umbrella directory paths that use .. to refer outside the module directory in module maps found via implicit search (-fimplicit-module-maps). This does not affect module maps specified explicitly via -fmodule-map-file=.

  • Honour [[maybe_unused]] attribute on private fields. -Wunused-private-field no longer emits a warning for annotated private fields.

Improvements to Clang’s time-trace

Improvements to Coverage Mapping

  • [MC/DC] Nested expressions are handled as individual MC/DC expressions.

  • “Single byte coverage” now supports branch coverage and can be used together with -fcoverage-mcdc.

Bug Fixes in This Version

  • Fixed atomic boolean compound assignment; the conversion back to atomic bool would be miscompiled. (#33210)

  • Fixed a failed assertion in the preprocessor when __has_embed parameters are missing parentheses. (#175088)

  • Fix lifetime extension of temporaries in for-range-initializers in templates. (#165182)

  • Fixed a preprocessor crash in __has_cpp_attribute on incomplete scoped attributes. (#178098)

  • Fixes an assertion failure when evaluating __underlying_type on enum redeclarations. (#177943)

  • Fixed an assertion failure caused by nested macro expansion during header-name lexing (__has_embed(__has_include)). (#178635)

  • Clang now outputs relative paths of embeds for dependency output. (#161950)

  • Fix the result type of a binary operation where both operands are ‘void’ l-values. (#111300)

  • Fixed an assertion failure when evaluating _Countof on invalid void-typed operands. (#180893)

  • Fixed an assertion failure in the serialized diagnostic printer when it is destroyed without calling finish(). (#140433)

  • Fixed an assertion failure caused by error recovery while extending a nested name specifier with results from ordinary lookup. (#181470)

  • Fixed a crash when parsing #pragma clang attribute arguments for attributes that forbid arguments. (#182122)

  • Fixed a bug with multiple-include optimization (MIOpt) state not being preserved in some cases during lexing, which could suppress header-guard mismatch diagnostics and interfere with include-guard optimization. (#180155)

  • Fixed a crash when normalizing constraints involving concept template parameters whose index coincided with non-concept template parameters in the same parameter mapping.

  • Fixed a crash caused by accessing dependent diagnostics of a non-dependent context.

  • Fixed a crash when substituting into a non-type template parameter that has a type containing an undeduced placeholder type.

  • Fixed several crashes and improved diagnostics when a multidimensional subscript operator is applied to a built-in type. (#187800)

  • Correctly diagnosing and no longer crashing when export module foo (without a semicolon) are the final tokens in a module file. (#187771)

  • Fixed a crash in duplicate attribute checking caused by comparing constant arguments with different integer signedness. (#188259)

Bug Fixes to Compiler Builtins

  • Fix a crash when passing an unresolved overload set to __builtin_classify_type. (#175589)

  • Fixed a crash when calling __builtin_allow_sanitize_check with no arguments. (#183927)

Bug Fixes to Attribute Support

  • Fixed a behavioral discrepancy between deleted functions and private members when checking the enable_if attribute. (#175895)

  • Fixed init_priority attribute by delaying type checks until after the type is deduced.

Bug Fixes to C++ Support

  • Fixed a crash on error recovery when dealing with invalid templates. (#183075)

  • Fixed a crash when instantiating requires expressions involving substitution failures in C++ concepts. (#176402)

  • Fixed an incorrect template argument deduction when matching packs of template template parameters when one of its parameters is also a pack. (#181166)

  • Fixed a crash when a default argument is passed to an explicit object parameter. (#176639)

  • Fixed an alias template CTAD crash.

  • Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#177741)

  • Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#176152)

  • Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#180307)

  • Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable when used inside decltype in the return type. (#180460)

  • Fixed a crash when evaluating uninitialized GCC vector/ext_vector_type vectors in constexpr. (#180044)

  • Fixed a crash when explicit(bool) is used with an incomplete enumeration. (#183887)

  • Fixed a crash on typeid of incomplete local types during template instantiation. (#63242), (#176397)

  • Fixed a crash when an immediate-invoked consteval lambda is used as an invalid initializer. (#185270)

  • Fixed an assertion failure when using a global destructor with a target with a non-default program address space. (#186484)

  • Inherited constructors in dllexport classes are now exported for ABI-compatible cases, matching MSVC behavior. Constructors with variadic arguments or callee-cleanup parameters are not yet supported and produce a warning. (#162640)

  • Fix initialization of GRO when GRO-return type mismatches, as part of CWG2563. (#98744)

  • Fix an error using an initializer list with array new for a type that is not default-constructible. (#81157)

  • We no longer consider conversion operators when copy-initializing from the same type. This was non conforming and could lead to recursive constraint satisfaction checking. (#149443)

Bug Fixes to AST Handling

  • Fixed a bug where explicit nullability property attributes were not stored in AST nodes in Objective-C. (#179703)

  • Fixed a crash when parsing Doxygen @param commands attached to invalid declarations or non-function entities. (#182737)

  • Fixed a assertion when __block is used on global variables in C mode. (#183974)

Miscellaneous Bug Fixes

  • Fixed the arguments of the format attribute on __builtin_os_log_format. Previously, they were off by 1.

Miscellaneous Clang Crashes Fixed

  • Fixed a crash when attempting to jump over initialization of a variable with variably modified type. (#175540)

  • Fixed a crash when using loop hint with a value dependent argument inside a generic lambda. (#172289)

  • Fixed a crash in C++ overload resolution with _Atomic-qualified argument types. (#170433)

  • Fixed a crash related to missing source locations (#186655)

  • Fixed a crash when casting a parenthesized unresolved template-id or array section. (#183505)

  • Fixed a crash when initializing a constexpr pointer with a floating-point literal in C23. (#180313)

  • Fixed an assertion when diagnosing address-space qualified new/delete in language-defined address spaces such as OpenCL __local. (#178319)

  • Fixed an assertion failure in ObjC++ ARC when binding a rvalue reference to reference with different lifetimes (#178524)

  • Fixed a crash when subscripting a vector type with large unsigned integer values. (#180563)

  • Fixed a crash when evaluating __is_bitwise_cloneable on invalid record types. (#183707)

  • Fixed an assertion failure when casting a function pointer with a target with a non-default program address space. (#186210)

  • Fixed a crash when decltype(__builtin_FUNCTION()) is used as a template type argument. (#167433)

  • Fixed an assertion failure when parsing an invalid decltype specifier with missing parentheses or extra semicolons. (#188014)

OpenACC Specific Changes

Target Specific Changes

AMDGPU Support

  • Introduced a new target specific builtin __builtin_amdgcn_processor_is, a late / deferred query for the current target processor.

  • Introduced a new target specific builtin __builtin_amdgcn_is_invocable, a late / deferred query for the availability of target specific builtins.

  • Initial support for gfx1310

NVPTX Support

X86 Support

  • march=znver6 is now supported.

Arm and AArch64 Support

Android Support

Windows Support

  • Clang now defines the _MSVC_TRADITIONAL macro as 1 when emulating MSVC 19.15 (Visual Studio 2017 version 15.8) and later. (#47114)

LoongArch Support

  • DWARF fission is now compatible with linker relaxations, allowing -gsplit-dwarf and -mrelax to be used together when building for the LoongArch platform.

RISC-V Support

  • Tenstorrent Ascalon D8 was renamed to Ascalon X. Use tt-ascalon-x with -mcpu or -mtune.

  • Intrinsics were added for the ‘Zvabd` (RISC-V Integer Vector Absolute Difference) extension.

CUDA/HIP Language Changes

  • The new offloading driver is now the default for HIP. Use –no-oflfoad-new-driver to return to the old behavior.

CUDA Support

AIX Support

NetBSD Support

WebAssembly Support

  • Fixed a crash when __funcref is applied to a non-function pointer type. (#118233)

AVR Support

SystemZ Support

  • Add support for #pragma export for z/OS. This is a pragma used to export functions and variables with external linkage from shared libraries. It provides compatibility with the IBM XL C/C++ compiler.

DWARF Support in Clang

Floating Point Support in Clang

Fixed Point Support in Clang

AST Matchers

  • Add functionTypeLoc matcher for matching FunctionTypeLoc.

  • Add missing support for TraversalKind in some addMatcher() overloads.

clang-format

  • Add ObjCSpaceAfterMethodDeclarationPrefix option to control space between the ‘-‘/’+’ and the return type in Objective-C method declarations

  • Add AfterComma value to BreakConstructorInitializers to allow breaking constructor initializers after commas, keeping the colon on the same line.

  • Extend BreakBinaryOperations to accept a structured configuration with per-operator break rules and minimum chain length gating via PerOperator.

  • Add AllowShortRecordOnASingleLine option and set it to EmptyAndAttached for LLVM style.

libclang

  • Visit constraints of auto type to properly visit concept usages (#166580)

  • Visit switch initializer statements (https://bugs.kde.org/show_bug.cgi?id=415537#c2)

  • Fix crash in clang_getBinaryOperatorKindSpelling and clang_getUnaryOperatorKindSpelling

  • The clang_Module_getASTFile API is deprecated and now always returns nullptr

Code Completion

  • Fixed a crash in code completion when using a C-Style cast with a parenthesized operand in Objective-C++ mode. (#180125)

Static Analyzer

Sanitizers

Python Binding Changes

  • Add deprecation warnings to CompletionChunk.isKind... methods. These will be removed in a future release. Existing uses should be adapted to directly compare equality of the CompletionChunk kind with the corresponding CompletionChunkKind variant.

    Affected methods: isKindOptional, isKindTypedText, isKindPlaceHolder, isKindInformative and isKindResultType.

  • Add a deprecation warning to CodeCompletionResults.results. This property will become an implementation detail with changed behavior in a future release and should not be used directly.. Existing uses of CodeCompletionResults.results should be changed to directly use CodeCompletionResults: it nows supports __len__ and __getitem__, so it can be used the same as CodeCompletionResults.results.

  • Added a new helper method get_clang_version to the class Config to read the version string of the libclang in use.

OpenMP Support

  • Added support for transparent clause in task and taskloop directives.

  • Added support for use_device_ptr clause to accept an optional fallback modifier (fb_nullify or fb_preserve) with OpenMP >= 61.

Improvements

Additional Information

A wide variety of additional information is available on the Clang web page. The web page contains versions of the API documentation which are up-to-date with the Git version of the source code. You can access versions of these documents specific to this release by going into the “clang/docs/” directory in the Clang tree.

If you have any questions or comments about Clang, please feel free to contact us on the Discourse forums (Clang Frontend category).