Clang 15 |ReleaseNotesTitle|

Written by the LLVM Team

Introduction

This document contains the release notes for the Clang C/C++/Objective-C frontend, part of the LLVM Compiler Infrastructure, release 15. 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

These changes are ones which we think may surprise users when upgrading to Clang 15 because of the opportunity they pose for disruption to existing code bases.

ABI Changes in This Version

  • Following the SystemV ABI for x86-64, __int128 arguments will no longer be split between a register and a stack slot.

What’s New in Clang 15?

Some of the major new features and improvements to Clang are listed here. Generic improvements to Clang as a whole or to its underlying infrastructure are described first, followed by language-specific sections with improvements to Clang’s support for those languages.

C++ Language Changes

C++20 Feature Support

C++23 Feature Support

C++2c Feature Support

  • Implemented P2169R4: A nice placeholder with no name. This allows using _ as a variable name multiple times in the same scope and is supported in all C++ language modes as an extension. An extension warning is produced when multiple variables are introduced by _ in the same scope. Unused warnings are no longer produced for variables named _. Currently, inspecting placeholders variables in a debugger when more than one are declared in the same scope is not supported.

    struct S {
      int _, _; // Was invalid, now OK
    };
    void func() {
      int _, _; // Was invalid, now OK
    }
    void other() {
      int _; // Previously diagnosed under -Wunused, no longer diagnosed
    }
    
  • Attributes now expect unevaluated strings in attributes parameters that are string literals. This is applied to both C++ standard attributes, and other attributes supported by Clang. This completes the implementation of P2361R6 Unevaluated Strings

Resolutions to C++ Defect Reports

C Language Changes

  • structs, unions, and arrays that are const may now be used as constant expressions. This change is more consistent with the behavior of GCC.

C23 Feature Support

  • Clang now accepts -std=c23 and -std=gnu23 as language standard modes, and the __STDC_VERSION__ macro now expands to 202311L instead of its previous placeholder value. Clang continues to accept -std=c2x and -std=gnu2x as aliases for C23 and GNU C23, respectively.
  • Clang now supports requires c23 for module maps.

Modified Compiler Flags

  • -Woverriding-t-option is renamed to -Woverriding-option.
  • -Winterrupt-service-routine is renamed to -Wexcessive-regsave as a generalization

Attribute Changes in Clang

  • On X86, a warning is now emitted if a function with __attribute__((no_caller_saved_registers)) calls a function without __attribute__((no_caller_saved_registers)), and is not compiled with -mgeneral-regs-only
  • On X86, a function with __attribute__((interrupt)) can now call a function without __attribute__((no_caller_saved_registers)) provided that it is compiled with -mgeneral-regs-only
  • When a non-variadic function is decorated with the format attribute, Clang now checks that the format string would match the function’s parameters’ types after default argument promotion. As a result, it’s no longer an automatic diagnostic to use parameters of types that the format style supports but that are never the result of default argument promotion, such as float. (#59824:)

Improvements to Clang’s diagnostics

  • Clang constexpr evaluator now prints template arguments when displaying template-specialization function calls.
  • Clang contexpr evaluator now displays notes as well as an error when a constructor of a base class is not called in the constructor of its derived class.
  • Clang no longer emits -Wmissing-variable-declarations for variables declared with the register storage class.
  • Clang’s -Wtautological-negation-compare flag now diagnoses logical tautologies like x && !x and !x || x in expressions. This also makes -Winfinite-recursion diagnose more cases. (#56035:).
  • Clang constexpr evaluator now diagnoses compound assignment operators against uninitialized variables as a read of uninitialized object. (#51536)
  • Clang’s -Wfortify-source now diagnoses snprintf call that is known to result in string truncation. (#64871:). Also clang no longer emits false positive warnings about the output length of %g format specifier.

Bug Fixes in This Version

  • Fixed an issue where a class template specialization whose declaration is instantiated in one module and whose definition is instantiated in another module may end up with members associated with the wrong declaration of the class, which can result in miscompiles in some cases.
  • Fix crash on use of a variadic overloaded operator. (#42535)
  • Fix a hang on valid C code passing a function type as an argument to typeof to form a function declaration. (#64713)
  • Clang now reports missing-field-initializers warning for missing designated initializers in C++. (#56628)
  • Clang now respects -fwrapv and -ftrapv for __builtin_abs and abs builtins. (#45129, #45794)
  • Fixed an issue where accesses to the local variables of a coroutine during await_suspend could be misoptimized, including accesses to the awaiter object itself. (#56301) The current solution may bring performance regressions if the awaiters have non-static data members. See #64945 for details.
  • Clang now prints unnamed members in diagnostic messages instead of giving an empty ‘’. Fixes (#63759)
  • Fix crash in __builtin_strncmp and related builtins when the size value exceeded the maximum value representable by int64_t. Fixes (#64876)
  • Fixed an assertion if a function has cleanups and fatal erors. (#48974)
  • Clang now emits an error if it is not possible to deduce array size for a variable with incomplete array type. (#37257)
  • Clang’s -Wunused-private-field no longer warns on fields whose type is declared with [[maybe_unused]]. (#61334)
  • For function multi-versioning using the target or target_clones attributes, remove comdat for internal linkage functions. (#65114)
  • Clang now reports -Wformat for bool value and char specifier confusion in scanf. Fixes (#64987)

Bug Fixes to Compiler Builtins

Bug Fixes to Attribute Support

Bug Fixes to C++ Support

  • Clang limits the size of arrays it will try to evaluate at compile time to avoid memory exhaustion. This limit can be modified by -fconstexpr-steps. (#63562)
  • Fix a crash caused by some named unicode escape sequences designating a Unicode character whose name contains a -. (Fixes #64161)
  • Fix cases where we ignore ambiguous name lookup when looking up members. (#22413), (#29942), (#35574) and (#27224).
  • Clang emits an error on substitution failure within lambda body inside a requires-expression. This fixes: (#64138).
  • Update FunctionDeclBitfields.NumFunctionDeclBits. This fixes: (#64171).
  • Expressions producing nullptr are correctly evaluated by the constant interpreter when appearing as the operand of a binary comparison. (#64923)
  • Fix a crash when an immediate invocation is not a constant expression and appear in an implicit cast. (#64949).
  • Fix crash when parsing ill-formed lambda trailing return type. Fixes: (#64962) and (#28679).
  • Fix a crash caused by substitution failure in expression requirements. (#64172) and (#64723).
Fix crash when parsing the requires clause of some generic lambdas.
(#64689 <https://github.com/llvm/llvm-project/issues/64689>`_)

Bug Fixes to AST Handling

  • Fixed an import failure of recursive friend class template. Issue 64169
  • Remove unnecessary RecordLayout computation when importing UnaryOperator. The computed RecordLayout is incorrect if fields are not completely imported and should not be cached. Issue 64170

Miscellaneous Bug Fixes

Miscellaneous Clang Crashes Fixed

  • Fixed a crash when parsing top-level ObjC blocks that aren’t properly terminated. Clang should now also recover better when an @end is missing between blocks. Issue 64065
  • Fixed a crash when check array access on zero-length element. Issue 64564

Target Specific Changes

AMDGPU Support

  • Use pass-by-reference (byref) in stead of pass-by-value (byval) for struct arguments in C ABI. Callee is responsible for allocating stack memory and copying the value of the struct if modified. Note that AMDGPU backend still supports byval for struct arguments.

X86 Support

Arm and AArch64 Support

Windows Support

  • Fixed an assertion failure that occurred due to a failure to propagate MSInheritanceAttr attributes to class template instantiations created for explicit template instantiation declarations.
  • The -fno-auto-import option was added for MinGW targets. The option both affects code generation (inhibiting generating indirection via .refptr stubs for potentially auto imported symbols, generating smaller and more efficient code) and linking (making the linker error out on such cases). If the option only is used during code generation but not when linking, linking may succeed but the resulting executables may expose issues at runtime.

LoongArch Support

RISC-V Support

  • Unaligned memory accesses can be toggled by -m[no-]unaligned-access or the aliases -m[no-]strict-align.

CUDA/HIP Language Changes

CUDA Support

AIX Support

WebAssembly Support

AVR Support

Floating Point Support in Clang

  • Add __builtin_elementwise_log builtin for floating point types only.
  • Add __builtin_elementwise_log10 builtin for floating point types only.
  • Add __builtin_elementwise_log2 builtin for floating point types only.
  • Add __builtin_elementwise_exp builtin for floating point types only.
  • Add __builtin_elementwise_exp2 builtin for floating point types only.
  • Add __builtin_set_flt_rounds builtin for X86, x86_64, Arm and AArch64 only.
  • Add __builtin_elementwise_pow builtin for floating point types only.
  • Add __builtin_elementwise_bitreverse builtin for integer types only.
  • Add __builtin_elementwise_sqrt builtin for floating point types only.
  • __builtin_isfpclass builtin now supports vector types.

AST Matchers

  • Add convertVectorExpr.
  • Add dependentSizedExtVectorType.
  • Add macroQualifiedType.

libclang

  • Exposed arguments of clang::annotate.

Static Analyzer

  • Added a new checker core.BitwiseShift which reports situations where bitwise shift operators produce undefined behavior (because some operand is negative or too large).

Sanitizers

  • -fsanitize=signed-integer-overflow now instruments __builtin_abs and abs builtins.

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