2022-02-01 23:13:01 -08:00
===========================================
Clang |release| |ReleaseNotesTitle|
===========================================
2020-02-13 22:46:33 +01:00
.. contents ::
:local:
:depth: 2
Written by the `LLVM Team <https://llvm.org/> `_
2022-02-01 23:13:01 -08:00
.. only :: PreRelease
2020-02-13 22:46:33 +01:00
2022-02-01 23:13:01 -08:00
.. warning ::
These are in-progress notes for the upcoming Clang |version| release.
Release notes for previous releases can be found on
2023-03-05 00:56:15 +02:00
`the Releases Page <https://llvm.org/releases/> `_ .
2020-02-13 22:46:33 +01:00
Introduction
============
This document contains the release notes for the Clang C/C++/Objective-C
2022-02-01 23:13:01 -08:00
frontend, part of the LLVM Compiler Infrastructure, release |release|. Here we
2020-02-13 22:46:33 +01:00
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
2023-02-15 23:53:38 +02:00
documentation <https://llvm.org/docs/ReleaseNotes.html>`_. For the libc++ release notes,
see `this page <https://libcxx.llvm.org/ReleaseNotes.html> `_ . All LLVM releases
may be downloaded from the `LLVM releases web site <https://llvm.org/releases/> `_ .
2020-02-13 22:46:33 +01:00
For more information about Clang or LLVM, including information about the
latest release, please see the `Clang Web Site <https://clang.llvm.org> `_ or the
`LLVM Web Site <https://llvm.org> `_ .
2022-09-15 07:29:49 -04:00
Potentially Breaking Changes
============================
These changes are ones which we think may surprise users when upgrading to
Clang |release| because of the opportunity they pose for disruption to existing
code bases.
2023-02-15 23:53:38 +02:00
C/C++ Language Potentially Breaking Changes
-------------------------------------------
2023-02-16 17:49:39 -08:00
- Indirect edges of asm goto statements under certain circumstances may now be
split. In previous releases of clang, that means for the following code the
two inputs may have compared equal in the inline assembly. This is no longer
guaranteed (and necessary to support outputs along indirect edges, which is
now supported as of this release). This change is more consistent with the
behavior of GCC.
.. code-block :: c
foo: asm goto ("# %0 %1"::"i"(&&foo)::foo);
2023-02-15 23:53:38 +02:00
C++ Specific Potentially Breaking Changes
-----------------------------------------
2023-02-20 10:26:41 +08:00
- Clang won't search for coroutine_traits in std::experimental namespace any more.
Clang will only search for std::coroutine_traits for coroutines then.
2023-02-15 23:53:38 +02:00
ABI Changes in This Version
---------------------------
2023-02-22 23:20:18 +02:00
- `` __is_trivial `` has changed for a small category of classes with constrained default constructors (`#60697 <https://github.com/llvm/llvm-project/issues/60697> `_ ).
*FIXME: Remove this note if we've backported this change to the Clang 16 branch.*
2023-02-15 23:53:38 +02:00
2022-02-01 23:13:01 -08:00
What's New in Clang |release|?
==============================
2020-02-13 22:46:33 +01:00
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.
2023-02-15 23:53:38 +02:00
C++ Language Changes
--------------------
- Improved `` -O0 `` code generation for calls to `` std::forward_like `` . Similarly to
`` std::move, std::forward `` et al. it is now treated as a compiler builtin and implemented
directly rather than instantiating the definition from the standard library.
2023-02-17 19:45:30 +01:00
- Implemented `CWG2518 <https://wg21.link/CWG2518> `_ which allows `` static_assert(false) ``
to not be ill-formed when its condition is evaluated in the context of a template definition.
2020-02-13 22:46:33 +01:00
2023-02-15 23:53:38 +02:00
C++20 Feature Support
^^^^^^^^^^^^^^^^^^^^^
2023-03-10 09:10:37 +00:00
- Support for out-of-line definitions of constrained templates has been improved.
2023-03-11 18:39:33 +02:00
This partially fixes `#49620 <https://github.com/llvm/llvm-project/issues/49620> `_ .
2023-03-17 10:13:02 +02:00
- Lambda templates with a requires clause directly after the template parameters now parse
correctly if the requires clause consists of a variable with a dependent type.
(`#61278 <https://github.com/llvm/llvm-project/issues/61278> `_ )
2023-03-16 11:02:06 +08:00
- Announced C++20 Coroutines is fully supported on all targets except Windows, which
still has some stability and ABI issues.
2023-03-28 08:52:37 -04:00
- Downgraded use of a reserved identifier in a module export declaration from
an error to a warning under the `` -Wreserved-module-identifier `` warning
group. This warning is enabled by default. This addresses `#61446
<https://github.com/llvm/llvm-project/issues/61446>`_ and allows easier
2023-04-10 12:53:50 -04:00
building of standard modules. This diagnostic may be strengthened into an
2023-03-28 08:52:37 -04:00
error again in the future once there is a less fragile way to mark a module
as being part of the implementation rather than a user module.
2022-03-12 20:49:01 +01:00
2023-02-15 23:53:38 +02:00
C++2b Feature Support
^^^^^^^^^^^^^^^^^^^^^
2022-02-06 22:58:43 +01:00
- Implemented `P2036R3: Change scope of lambda trailing-return-type <https://wg21.link/P2036R3> `_
and `P2579R0 Mitigation strategies for P2036 <https://wg21.link/P2579R0> `_ .
These proposals modify how variables captured in lambdas can appear in trailing return type
expressions and how their types are deduced therein, in all C++ language versions.
2023-02-15 23:53:38 +02:00
Resolutions to C++ Defect Reports
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-10 15:08:45 +08:00
- Implemented `DR2397 <https://wg21.link/CWG2397> `_ which allows `` auto `` specifier for pointers
and reference to arrays.
2023-02-15 23:53:38 +02:00
C Language Changes
------------------
2023-02-16 17:49:39 -08:00
- Support for outputs from asm goto statements along indirect edges has been
2023-03-11 18:39:33 +02:00
added. (`#53562 <https://github.com/llvm/llvm-project/issues/53562> `_ )
2023-04-20 08:01:23 -04:00
- Fixed a bug that prevented initialization of an `` _Atomic `` -qualified pointer
from a null pointer constant.
2023-04-20 10:20:54 -04:00
- Fixed a bug that prevented casting to an `` _Atomic `` -qualified type.
(`#39596 <https://github.com/llvm/llvm-project/issues/39596> `_ )
2023-02-15 23:53:38 +02:00
C2x Feature Support
^^^^^^^^^^^^^^^^^^^
- Implemented the `` unreachable `` macro in freestanding `` <stddef.h> `` for
`WG14 N2826 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2826.pdf> `_
2022-08-26 09:17:14 -04:00
2023-02-24 13:52:41 -05:00
- Removed the `` ATOMIC_VAR_INIT `` macro in C2x and later standards modes, which
implements `WG14 N2886 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm> `_
[C2x] Implement support for revised spelling of keywords
This implements WG14 N2934
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2934.pdf), which
adds keywords for alignas, alignof, bool, static_assert, and
thread_local in C, as aliases for _Alignas, _Alignof, _Bool,
_Static_assert, and _Thread_local. We already supported the keywords in
C2x mode, but this completes support by adding pre-C2x compat warnings
and updates the stdalign.h header in freestanding mode.
2023-02-25 09:27:46 -05:00
- Implemented `WG14 N2934 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2934.pdf> `_
which introduces the `` bool `` , `` static_assert `` , `` alignas `` , `` alignof `` ,
and `` thread_local `` keywords in C2x.
2023-04-03 15:19:15 -04:00
- Implemented `WG14 N2900 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2900.htm> `_
and `WG14 N3011 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3011.htm> `_
which allows for empty braced initialization in C.
.. code-block :: c
struct S { int x, y } s = {}; // Initializes s.x and s.y to 0
As part of this change, the `` -Wgnu-empty-initializer `` warning group was
removed, as this is no longer a GNU extension but a C2x extension. You can
use `` -Wno-c2x-extensions `` to silence the extension warning instead.
[C2x] Update 'nullptr' implementation based on CD comments
We filed some CD ballot comments which WG14 considered during the
ballot comment resolution meetings in Jan and Feb 2023, and this
updates our implementation based on the decisions reached. Those
decisions were (paraphrased for brevity):
US 9-034 (REJECTED)
allow (void *)nullptr to be a null pointer constant
US 10-035 (ACCEPTED)
accept the following code, as in C++:
void func(nullptr_t); func(0);
US 22-058 (REJECTED)
accept the following code, as in C++:
nullptr_t val; (void)(1 ? val : 0); (void)(1 ? nullptr : 0);
US 23-062 (REJECTED)
reject the following code, as in C++:
nullptr_t val; bool b1 = val; bool b2 = nullptr;
US 24-061 (ACCEPTED)
accept the following code, as in C++:
nullptr_t val; val = 0;
US 21-068 (ACCEPTED)
accept the following code, as in C++:
(nullptr_t)nullptr;
GB-071 (ACCEPTED)
accept the following code, as in C++:
nullptr_t val; (void)(val == nullptr);
This patch updates the implementation as appropriate, but is primarily
focused around US 10-035, US 24-061, and US 23-062 in terms of
functional changes.
Differential Revision: https://reviews.llvm.org/D148800
2023-05-03 14:06:04 -04:00
- Updated the implementation of
`WG14 N3042 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3042.htm> `_
based on decisions reached during the WG14 CD Ballot Resolution meetings held
in Jan and Feb 2023. This should complete the implementation of `` nullptr ``
and `` nullptr_t `` in C. The specific changes are:
.. code-block :: c
void func(nullptr_t);
func(0); // Previously required to be rejected, is now accepted.
func((void *)0); // Previously required to be rejected, is now accepted.
nullptr_t val;
val = 0; // Previously required to be rejected, is now accepted.
val = (void *)0; // Previously required to be rejected, is now accepted.
bool b = nullptr; // Was incorrectly rejected by Clang, is now accepted.
2022-08-26 10:04:06 -04:00
Non-comprehensive list of changes in this release
-------------------------------------------------
2023-01-06 15:52:22 -03:00
- Clang now saves the address of ABI-indirect function parameters on the stack,
improving the debug information available in programs compiled without
optimizations.
2023-02-02 17:42:31 +00:00
- Clang now supports `` __builtin_nondeterministic_value `` that returns a
nondeterministic value of the same type as the provided argument.
2023-03-17 09:50:34 -04:00
- Clang now supports `` __builtin_FILE_NAME() `` which returns the same
information as the `` __FILE_NAME__ `` macro (the presumed file name
from the invocation point, with no path components included).
2023-03-23 14:34:12 -07:00
- Clang now supports `` __builtin_assume_separate_storage `` that indicates that
its arguments point to objects in separate storage allocations.
2023-03-24 17:14:11 +03:00
- Clang now supports expressions in `` #pragma clang __debug dump `` .
2023-04-05 08:10:57 -07:00
- Clang now supports declaration of multi-dimensional arrays with
`` __declspec(property) `` .
2023-03-29 17:58:25 +02:00
- A new builtin type trait `` __is_trivially_equaltiy_comparable `` has been added,
which checks whether comparing two instances of a type is equivalent to
`` memcmp(&lhs, &rhs, sizeof(T)) == 0 `` .
2023-04-27 13:43:18 -04:00
- Clang now ignores null directives outside of the include guard when deciding
whether a file can be enabled for the multiple-include optimization.
2022-08-26 09:17:14 -04:00
2020-02-13 22:46:33 +01:00
New Compiler Flags
------------------
Deprecated Compiler Flags
-------------------------
Modified Compiler Flags
-----------------------
2023-01-23 13:25:55 +02:00
2020-12-17 09:23:02 -05:00
Removed Compiler Flags
-------------------------
2023-02-15 18:30:49 +08:00
- The deprecated flag `-fmodules-ts` is removed. Please use `` -std=c++20 ``
or higher to use standard C++ modules instead.
2023-02-23 14:31:41 +08:00
- The deprecated flag `-fcoroutines-ts` is removed. Please use `` -std=c++20 ``
or higher to use standard C++ coroutines instead.
2023-03-09 11:32:17 -08:00
- The CodeGen flag `-lower-global-dtors-via-cxa-atexit` which affects how global
destructors are lowered for MachO is removed without replacement. The default
of `-lower-global-dtors-via-cxa-atexit=true` is now the only supported way.
2020-12-17 09:23:02 -05:00
2020-02-13 22:46:33 +01:00
Attribute Changes in Clang
--------------------------
2023-02-15 23:53:38 +02:00
- Introduced a new function attribute `` __attribute__((unsafe_buffer_usage)) ``
to be worn by functions containing buffer operations that could cause out of
bounds memory accesses. It emits warnings at call sites to such functions when
the flag `` -Wunsafe-buffer-usage `` is enabled.
- `` __declspec `` attributes can now be used together with the using keyword. Before
the attributes on `` __declspec `` was ignored, while now it will be forwarded to the
point where the alias is used.
2023-02-23 14:14:14 -08:00
- Introduced a new `` USR `` (unified symbol resolution) clause inside of the
2023-02-23 15:52:21 -08:00
existing `` __attribute__((external_source_symbol)) `` attribute. Clang's indexer
uses the optional USR value when indexing Clang's AST. This value is expected
to be generated by an external compiler when generating C++ bindings during
the compilation of the foreign language sources (e.g. Swift).
2023-02-12 22:12:08 +01:00
- The `` __has_attribute `` , `` __has_c_attribute `` and `` __has_cpp_attribute ``
preprocessor operators now return 1 also for attributes defined by plugins.
2023-01-20 23:31:53 +00:00
2023-02-15 23:53:38 +02:00
Improvements to Clang's diagnostics
-----------------------------------
- We now generate a diagnostic for signed integer overflow due to unary minus
in a non-constant expression context.
2023-03-11 18:39:33 +02:00
(`#31643 <https://github.com/llvm/llvm-project/issues/31643> `_ )
2023-02-15 23:53:38 +02:00
- Clang now warns by default for C++20 and later about deprecated capture of
`` this `` with a capture default of `` = `` . This warning can be disabled with
`` -Wno-deprecated-this-capture `` .
2023-03-01 23:29:45 +01:00
- Clang had failed to emit some `` -Wundefined-internal `` for members of a local
class if that class was first introduced with a forward declaration.
2023-03-06 08:16:16 -08:00
- Diagnostic notes and fix-its are now generated for `` ifunc `` /`` alias `` attributes
which point to functions whose names are mangled.
2023-03-01 14:53:23 +00:00
- Diagnostics relating to macros on the command line of a preprocessed assembly
2023-04-24 14:07:41 +01:00
file or precompiled header are now reported as coming from the file
`` <command line> `` instead of `` <built-in> `` .
2023-03-13 12:53:12 -04:00
- Clang constexpr evaluator now provides a more concise diagnostic when calling
function pointer that is known to be null.
2023-03-14 08:43:35 -04:00
- Clang now avoids duplicate warnings on unreachable `` [[fallthrough]]; `` statements
previously issued from `` -Wunreachable-code `` and `` -Wunreachable-code-fallthrough ``
by prioritizing `` -Wunreachable-code-fallthrough `` .
2023-03-17 09:54:39 -07:00
- Clang now correctly diagnoses statement attributes `` [[clang::always_inine]] `` and
`` [[clang::noinline]] `` when used on a statement with dependent call expressions.
2023-03-27 14:45:43 -04:00
- Clang now checks for completeness of the second and third arguments in the
conditional operator.
(`#59718 <https://github.com/llvm/llvm-project/issues/59718> `_ )
2023-04-06 14:40:39 -07:00
- There were some cases in which the diagnostic for the unavailable attribute
might not be issued, this fixes those cases.
(`61815 <https://github.com/llvm/llvm-project/issues/61815> `_ )
2023-04-07 08:08:47 -04:00
- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
the case of binary operators with logical OR operations.
(`#57906 <https://github.com/llvm/llvm-project/issues/57906> `_ )
2023-04-13 08:14:14 -04:00
- Clang's "static assertion failed" diagnostic now points to the static assertion
expression instead of pointing to the `` static_assert `` token.
(`#61951 <https://github.com/llvm/llvm-project/issues/61951> `_ )
2023-04-20 09:34:34 -07:00
- `` -Wformat `` now recognizes `` %lb `` for the `` printf `` /`` scanf `` family of
functions.
(`#62247: <https://github.com/llvm/llvm-project/issues/62247> `_ ).
2023-04-28 06:26:35 -04:00
- Clang now diagnoses shadowing of lambda's template parameter by a capture.
(`#61105: <https://github.com/llvm/llvm-project/issues/61105> `_ ).
2023-01-31 11:43:34 -08:00
2023-02-15 23:53:38 +02:00
Bug Fixes in This Version
-------------------------
2023-02-09 10:53:39 +01:00
2023-04-26 17:45:27 +05:30
- Fix segfault while running clang-rename on a non existing file.
(`#36471 <https://github.com/llvm/llvm-project/issues/36471> `_ )
2023-02-15 23:53:38 +02:00
- Fix crash when diagnosing incorrect usage of `` _Nullable `` involving alias
templates.
(`#60344 <https://github.com/llvm/llvm-project/issues/60344> `_ )
- Fix confusing warning message when `` /clang:-x `` is passed in `` clang-cl ``
driver mode and emit an error which suggests using `` /TC `` or `` /TP ``
`` clang-cl `` options instead.
(`#59307 <https://github.com/llvm/llvm-project/issues/59307> `_ )
2023-02-13 21:06:07 -08:00
- Fix assert that fails when the expression causing the this pointer to be
captured by a block is part of a constexpr if statement's branch and
instantiation of the enclosing method causes the branch to be discarded.
2023-02-17 14:56:02 -08:00
- Fix __VA_OPT__ implementation so that it treats the concatenation of a
non-placemaker token and placemaker token as a non-placemaker token.
(`#60268 <https://github.com/llvm/llvm-project/issues/60268> `_ )
2023-02-23 11:04:23 +01:00
- Fix crash when taking the address of a consteval lambda call operator.
(`#57682 <https://github.com/llvm/llvm-project/issues/57682> `_ )
2023-03-03 10:31:48 +08:00
- Clang now support export declarations in the language linkage.
(`#60405 <https://github.com/llvm/llvm-project/issues/60405> `_ )
2023-03-06 03:25:57 -05:00
- Fix aggregate initialization inside lambda constexpr.
(`#60936 <https://github.com/llvm/llvm-project/issues/60936> `_ )
2023-03-14 11:07:14 -04:00
- No longer issue a false positive diagnostic about a catch handler that cannot
be reached despite being reachable. This fixes
`#61177 <https://github.com/llvm/llvm-project/issues/61177> `_ in anticipation
of `CWG2699 <https://wg21.link/CWG2699>_` being accepted by WG21.
2023-03-15 01:07:55 +08:00
- Fix crash when parsing fold expression containing a delayed typo correction.
(`#61326 <https://github.com/llvm/llvm-project/issues/61326> `_ )
2023-03-14 16:27:55 -07:00
- Fix crash when dealing with some member accesses outside of class or member
function context.
(`#37792 <https://github.com/llvm/llvm-project/issues/37792> `_ ) and
(`#48405 <https://github.com/llvm/llvm-project/issues/48405> `_ )
2023-03-17 08:59:03 -07:00
- Fix crash when using `` [[clang::always_inline]] `` or `` [[clang::noinline]] ``
statement attributes on a call to a template function in the body of a
template function.
2023-03-08 16:00:02 -08:00
- Fix coroutines issue where `` get_return_object() `` result was always eargerly
converted to the return type. Eager initialization (allowing RVO) is now only
perfomed when these types match, otherwise deferred initialization is used,
enabling short-circuiting coroutines use cases. This fixes
(`#56532 <https://github.com/llvm/llvm-project/issues/56532> `_ ) in
antecipation of `CWG2563 <https://cplusplus.github.io/CWG/issues/2563.html>_` .
2023-03-23 14:16:25 -07:00
- Fix highlighting issue with `` _Complex `` and initialization list with more than
2 items. (`#61518 <https://github.com/llvm/llvm-project/issues/61518> `_ )
2023-03-27 10:13:20 +02:00
- Fix `` getSourceRange `` on `` VarTemplateSpecializationDecl `` and
`` VarTemplatePartialSpecializationDecl `` , which represents variable with
the initializer, so it behaves consistently with other `` VarDecls `` and ends
on the last token of initializer, instead of right angle bracket of
the template argument list.
2023-03-28 07:28:47 -04:00
- Fix false-positive diagnostic issued for consteval initializers of temporary
objects.
(`#60286 <https://github.com/llvm/llvm-project/issues/60286> `_ )
2023-03-28 11:12:50 -07:00
- Correct restriction of trailing requirements clauses on a templated function.
Previously we only rejected non-'templated' things, but the restrictions ALSO need
to limit non-defined/non-member functions as well. Additionally, we now diagnose
requires on lambdas when not allowed, which we previously missed.
(`#61748 <https://github.com/llvm/llvm-project/issues/61748> `_ )
2023-03-23 14:26:45 +01:00
- Fix confusing diagnostic for incorrect use of qualified concepts names.
2023-03-30 13:35:10 -07:00
- Fix handling of comments in function like macros so they are ignored in -CC
mode.
(`#60887 <https://github.com/llvm/llvm-project/issues/60887> `_ )
PR60985: Fix merging of lambda closure types across modules.
Previously, distinct lambdas would get merged, and multiple definitions
of the same lambda would not get merged, because we attempted to
identify lambdas by their ordinal position within their lexical
DeclContext. This failed for lambdas within namespace-scope variables
and within variable templates, where the lexical position in the context
containing the variable didn't uniquely identify the lambda.
In this patch, we instead identify lambda closure types by index within
their context declaration, which does uniquely identify them in a way
that's consistent across modules.
This change causes a deserialization cycle between the type of a
variable with deduced type and a lambda appearing as the initializer of
the variable -- reading the variable's type requires reading and merging
the lambda, and reading the lambda requires reading and merging the
variable. This is addressed by deferring loading the deduced type of a
variable until after we finish recursive deserialization.
This also exposes a pre-existing subtle issue where loading a
variable declaration would trigger immediate loading of its initializer,
which could recursively refer back to properties of the variable. This
particularly causes problems if the initializer contains a
lambda-expression, but can be problematic in general. That is addressed
by switching to lazily loading the initializers of variables rather than
always loading them with the variable declaration. As well as fixing a
deserialization cycle, that should improve laziness of deserialization
in general.
LambdaDefinitionData had 63 spare bits in it, presumably caused by an
off-by-one-error in some previous change. This change claims 32 of those bits
as a counter for the lambda within its context. We could probably move the
numbering to separate storage, like we do for the device-side mangling number,
to optimize the likely-common case where all three numbers (host-side mangling
number, device-side mangling number, and index within the context declaration)
are zero, but that's not done in this change.
Fixes #60985.
Reviewed By: #clang-language-wg, aaron.ballman
Differential Revision: https://reviews.llvm.org/D145737
2023-03-30 14:21:31 -07:00
- Fix incorrect merging of lambdas across modules.
(`#60985 <https://github.com/llvm/llvm-project/issues/60985> `_ )
2023-04-05 05:01:42 -04:00
- Fix crash when handling nested immediate invocations in initializers of global
variables.
(`#58207 <https://github.com/llvm/llvm-project/issues/58207> `_ )
2023-03-29 17:58:25 +02:00
- Fix crash when generating code coverage information for `PseudoObjectExpr` in
2023-04-05 14:43:52 -04:00
Clang AST.
(`#45481 <https://github.com/llvm/llvm-project/issues/45481> `_ )
2023-04-06 04:34:07 -04:00
- Fix the assertion hit when a template consteval function appears in a nested
consteval/constexpr call chain.
(`#61142 <https://github.com/llvm/llvm-project/issues/61142> `_ )
2023-04-10 11:52:30 +02:00
- Clang now better diagnose placeholder types constrained with a concept that is
not a type concept.
2023-04-11 16:32:31 +02:00
- Fix crash when a doc comment contains a line splicing.
(`#62054 <https://github.com/llvm/llvm-project/issues/62054> `_ )
2023-01-23 22:05:48 +01:00
- Work around with a clang coverage crash which happens when visiting
expressions/statements with invalid source locations in non-assert builds.
2023-03-28 12:55:47 -04:00
Assert builds may still see assertions triggered from this.
2023-04-14 07:18:46 -04:00
- Fix a failed assertion due to an invalid source location when trying to form
a coverage report for an unresolved constructor expression.
2023-03-28 12:55:47 -04:00
(`#62105 <https://github.com/llvm/llvm-project/issues/62105> `_ )
2023-04-14 14:56:36 -07:00
- Fix defaulted equality operator so that it does not attempt to compare unnamed
bit-fields. This fixes:
(`#61355 <https://github.com/llvm/llvm-project/issues/61335> `_ ) and
(`#61417 <https://github.com/llvm/llvm-project/issues/61417> `_ )
2023-04-17 07:53:43 -04:00
- Fix crash after suggesting typo correction to constexpr if condition.
(`#61885 <https://github.com/llvm/llvm-project/issues/61885> `_ )
2023-04-17 09:48:58 -04:00
- Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
member pointer as an invalid expression.
2023-04-25 23:08:28 +02:00
- Fix crash when member function contains invalid default argument.
(`#62122 <https://github.com/llvm/llvm-project/issues/62122> `_ )
2023-04-27 05:24:31 -04:00
- Fix crash when handling undefined template partial specialization
(`#61356 <https://github.com/llvm/llvm-project/issues/61356> `_ )
2023-04-30 15:13:22 -07:00
- Fix premature substitution into the constraints of an inherited constructor.
2023-04-26 14:50:01 -07:00
- Fix crash when attempting to perform parenthesized initialization of an
aggregate with a base class with only non-public constructors.
2023-04-27 11:41:09 -07:00
(`#62296 <https://github.com/llvm/llvm-project/issues/62296> `_ )
2023-01-23 22:05:48 +01:00
- Fix a stack overflow issue when evaluating `` consteval `` default arguments.
(`#60082` <https://github.com/llvm/llvm-project/issues/60082> `_ )
2023-05-02 08:20:29 -04:00
- Fix the assertion hit when generating code for global variable initializer of
_BitInt(1) type.
(`#62207 <https://github.com/llvm/llvm-project/issues/62207> `_ )
2023-05-02 11:53:48 -04:00
- Fix lambdas and other anonymous function names not respecting `` -fdebug-prefix-map ``
(`#62192 <https://github.com/llvm/llvm-project/issues/62192> `_ )
2023-03-29 06:37:01 -07:00
2023-02-15 23:53:38 +02:00
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-05-02 17:06:04 -04:00
2023-02-15 23:53:38 +02:00
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-26 15:29:02 -04:00
- Fixed a bug where attribute annotations on type specifiers (enums, classes,
structs, unions, and scoped enums) were not properly ignored, resulting in
misleading warning messages. Now, such attribute annotations are correctly
ignored. (`#61660 <https://github.com/llvm/llvm-project/issues/61660> `_ )
2022-08-26 19:26:32 +08:00
2023-02-15 23:53:38 +02:00
Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
2023-01-18 08:49:45 -05:00
2023-02-15 23:53:38 +02:00
- Fix crash on invalid code when looking up a destructor in a templated class
inside a namespace.
(`#59446 <https://github.com/llvm/llvm-project/issues/59446> `_ )
- Fix crash when evaluating consteval constructor of derived class whose base
has more than one field.
(`#60166 <https://github.com/llvm/llvm-project/issues/60166> `_ )
2023-03-07 21:08:57 +08:00
- Fix an issue about `` decltype `` in the members of class templates derived from
templates with related parameters.
(`#58674 <https://github.com/llvm/llvm-project/issues/58674> `_ )
2023-03-11 18:40:44 +02:00
- Fix incorrect deletion of the default constructor of unions in some
cases. (`#48416 <https://github.com/llvm/llvm-project/issues/48416> `_ )
2023-03-21 10:49:54 -04:00
- No longer issue a pre-C++2b compatibility warning in `` -pedantic `` mode
2023-03-21 12:48:13 -04:00
regading overloaded `operator[]` with more than one parmeter or for static
lambdas. (`#61582 <https://github.com/llvm/llvm-project/issues/61582> `_ )
2023-03-14 21:25:54 +02:00
- Stop stripping CV qualifiers from the type of `` this `` when capturing it by value in
a lambda.
(`#50866 <https://github.com/llvm/llvm-project/issues/50866> `_ )
2023-03-30 13:04:02 -07:00
- Fix ordering of function templates by constraints when they have template
template parameters with different nested constraints.
2023-03-30 13:08:22 -07:00
- Fix type equivalence comparison between auto types to take constraints into
account.
2023-03-11 18:39:33 +02:00
- Fix bug in the computation of the `` __has_unique_object_representations ``
builtin for types with unnamed bitfields.
(`#61336 <https://github.com/llvm/llvm-project/issues/61336> `_ )
[clang] Fix default initializers being ignored when initializing templated aggregate types
Previously, when checking whether an in-class initializer exists when
performing parenthesized aggregate initialization, Clang checks that the
output of FieldDecl::getInClassInitializer() is non-null. This is
incorrect; if the field is part of a templated type, then
getInClassInitializer() will return nullptr if we haven't called
Sem::BuildCXXDefaultInitExpr(...) before, even if
FieldDecl::hasInClassInitializer() returns true. The end result is that
Clang incorrectly ignores the in class initializer and
value-initializes the field. The fix therefore is to instead call
FieldDecl::hasInClassInitializer(), which is what we do for braced init
lists [0].
Before this patch, Clang does correctly recognize the in-class field
initializer in certain cases. This is Sema::BuildCXXDefaultInitExpr(...)
populates the in class initializer of the corresponding FieldDecl
object. Therefore, if that method was previously called with the same
FieldDecl object, as can happen with a decltype(...) or a braced list
initialization, FieldDecl::getInClassInitializer() will return a
non-null expression, and the field becomes properly initialized.
Fixes 62266
[0]: https://github.com/llvm/llvm-project/blob/be5f35e24f4c15caf3c4aeccddc54c52560c28a0/clang/lib/Sema/SemaInit.cpp#L685
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D149389
2023-04-27 15:31:51 -07:00
- Fix default member initializers sometimes being ignored when performing
parenthesized aggregate initialization of templated types.
(`#62266 <https://github.com/llvm/llvm-project/issues/62266> `_ )
2023-04-13 11:04:59 -07:00
- Fix overly aggressive lifetime checks for parenthesized aggregate
initialization.
(`#61567 <https://github.com/llvm/llvm-project/issues/61567> `_ )
2023-05-02 10:30:56 +02:00
- Fix a crash when expanding a pack as the index of a subscript expression.
2022-08-11 12:53:41 -07:00
2023-02-15 23:53:38 +02:00
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
2023-01-17 11:29:04 -08:00
2023-02-15 23:53:38 +02:00
Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
2020-02-13 22:46:33 +01:00
2023-02-15 23:53:38 +02:00
Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-05-03 14:13:56 -04:00
2023-04-06 09:52:39 -04:00
- Dumping the AST to JSON no longer causes a failed assertion when targetting
the Microsoft ABI and the AST to be dumped contains dependent names that
would not typically be mangled.
(`#61440 <https://github.com/llvm/llvm-project/issues/61440> `_ )
2023-02-15 23:53:38 +02:00
Target Specific Changes
-----------------------
2020-02-13 22:46:33 +01:00
2023-03-13 09:33:08 -05:00
AMDGPU Support
^^^^^^^^^^^^^^
- Linking for AMDGPU now uses `` --no-undefined `` by default. This causes
undefined symbols in the created module to be a linker error. To prevent this,
pass `` -Wl,--undefined `` if compiling directly, or `` -Xoffload-linker
--undefined`` if using an offloading language.
2023-03-23 14:26:45 +01:00
- The deprecated `` -mcode-object-v3 `` and `` -mno-code-object-v3 `` command-line
2023-03-27 13:27:31 +02:00
options have been removed.
2023-03-13 09:33:08 -05:00
2023-02-15 23:53:38 +02:00
X86 Support
^^^^^^^^^^^
2020-02-13 22:46:33 +01:00
2023-03-31 16:56:06 +08:00
- Add ISA of `` AMX-COMPLEX `` which supports `` tcmmimfp16ps `` and
`` tcmmrlfp16ps `` .
2023-02-15 23:53:38 +02:00
Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^
2020-02-13 22:46:33 +01:00
2023-02-15 23:53:38 +02:00
- The hard-float ABI is now available in Armv8.1-M configurations that
have integer MVE instructions (and therefore have FP registers) but
no scalar or vector floating point computation. Previously, trying
to select the hard-float ABI on such a target (via
`` -mfloat-abi=hard `` or a triple ending in `` hf `` ) would silently
use the soft-float ABI instead.
2020-02-13 22:46:33 +01:00
2023-02-15 23:53:38 +02:00
- Clang builtin `` __arithmetic_fence `` and the command line option `` -fprotect-parens ``
are now enabled for AArch64.
2022-02-02 13:06:55 -05:00
2023-04-24 22:13:30 -07:00
- Clang supports flag output operands by which conditions in the NZCV could be outputs
of inline assembly for AArch64. This change is more consistent with the behavior of
GCC.
.. code-block :: c
// int a = foo(); int* b = bar();
asm("ands %w[a], %w[a], #3" : [a] "+r"(a), "=@cceq"(*b));
2023-04-28 14:01:51 +02:00
- Fix a crash when `` preserve_all `` calling convention is used on AArch64.
`Issue 58145 <https://github.com/llvm/llvm-project/issues/58145> `_
2023-02-15 23:53:38 +02:00
Windows Support
^^^^^^^^^^^^^^^
2020-02-13 22:46:33 +01:00
2023-02-15 23:53:38 +02:00
LoongArch Support
^^^^^^^^^^^^^^^^^
2023-01-17 20:53:58 +08:00
2023-03-15 17:12:48 +08:00
- Patchable function entry (`` -fpatchable-function-entry `` ) is now supported
on LoongArch.
2023-02-15 23:53:38 +02:00
RISC-V Support
^^^^^^^^^^^^^^
2023-02-02 10:18:17 -08:00
- Added `` -mrvv-vector-bits= `` option to give an upper and lower bound on vector
length. Valid values are powers of 2 between 64 and 65536. A value of 32
should eventually be supported. We also accept "zvl" to use the Zvl*b
extension from `` -march `` or `` -mcpu `` to the be the upper and lower bound.
2023-03-26 16:18:47 +01:00
- Fixed incorrect ABI lowering of `` _Float16 `` in the case of structs
containing `` _Float16 `` that are eligible for passing via GPR+FPR or
FPR+FPR.
2023-04-27 11:21:55 -07:00
- Removed support for `` __attribute__((interrupt("user"))) `` . User-level
interrupts are not in version 1.12 of the privileged specification.
2023-04-28 15:41:17 -07:00
- Added `` attribute(riscv_rvv_vector_bits(__riscv_v_fixed_vlen)) `` to allow
the size of a RVV (RISC-V Vector) scalable type to be specified. This allows
RVV scalable vector types to be used in structs or in global variables.
2022-08-18 14:39:37 -07:00
2023-02-15 23:53:38 +02:00
CUDA/HIP Language Changes
^^^^^^^^^^^^^^^^^^^^^^^^^
2022-10-18 10:50:37 -07:00
2023-02-15 23:53:38 +02:00
CUDA Support
^^^^^^^^^^^^
2022-01-23 20:45:25 -08:00
2023-02-15 23:53:38 +02:00
AIX Support
^^^^^^^^^^^
2023-03-27 18:04:05 +00:00
- Add an AIX-only link-time option, `-mxcoff-build-id=0xHEXSTRING` , to allow users
to embed a hex id in their binary such that it's readable by the program itself.
This option is an alternative to the `--build-id=0xHEXSTRING` GNU linker option
which is currently not supported by the AIX linker.
[Clang][AArch64] Support AArch64 target(..) attribute formats.
This adds support under AArch64 for the target("..") attributes. The
current parsing is very X86-shaped, this patch attempts to bring it line
with the GCC implementation from
https://gcc.gnu.org/onlinedocs/gcc/AArch64-Function-Attributes.html#AArch64-Function-Attributes.
The supported formats are:
- "arch=<arch>" strings, that specify the architecture features for a
function as per the -march=arch+feature option.
- "cpu=<cpu>" strings, that specify the target-cpu and any implied
atributes as per the -mcpu=cpu+feature option.
- "tune=<cpu>" strings, that specify the tune-cpu cpu for a function as
per -mtune.
- "+<feature>", "+no<feature>" enables/disables the specific feature, for
compatibility with GCC target attributes.
- "<feature>", "no-<feature>" enabled/disables the specific feature, for
backward compatibility with previous releases.
To do this, the parsing of target attributes has been moved into
TargetInfo to give the target the opportunity to override the existing
parsing. The only non-aarch64 change should be a minor alteration to the
error message, specifying using "CPU" to describe the cpu, not
"architecture", and the DuplicateArch/Tune from ParsedTargetAttr have
been combined into a single option.
Differential Revision: https://reviews.llvm.org/D133848
2022-10-01 15:40:59 +01:00
2023-02-15 23:53:38 +02:00
WebAssembly Support
^^^^^^^^^^^^^^^^^^^
[ARM] Allow selecting hard-float ABI in integer-only MVE.
Armv8.1-M can be configured to support the integer subset of the MVE
vector instructions, and no floating point. In that situation, the FP
and vector registers still exist, and so do the load, store and move
instructions that transfer data in and out of them. So there's no
reason the hard floating point ABI can't be supported, and you might
reasonably want to use it, for the sake of intrinsics-based code
passing explicit MVE vector types between functions.
But the selection of the hard float ABI in the backend was gated on
Subtarget->hasVFP2Base(), which is false in the case of integer MVE
and no FP.
As a result, you'd silently get the soft float ABI even if you
deliberately tried to select it, e.g. with clang options such as
--target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+nofp+mve
The hard float ABI should have been gated on the weaker condition
Subtarget->hasFPRegs(), because the only requirement for being able to
pass arguments in the FP registers is that the registers themselves
should exist.
I haven't added a new test, because changing the existing
CodeGen/Thumb2/float-ops.ll test seemed sufficient. But I've added a
comment explaining why the results are expected to be what they are.
Reviewed By: lenary
Differential Revision: https://reviews.llvm.org/D142703
2023-01-31 17:31:33 +00:00
2022-02-06 08:20:54 -05:00
AVR Support
^^^^^^^^^^^
- The definition of `` USHRT_MAX `` in the freestanding `` <limits.h> `` no longer
overflows on AVR (where `` sizeof(int) == sizeof(unsigned short) `` ). The type
of `` USHRT_MAX `` is now `` unsigned int `` instead of `` int `` , as required by
the C standard.
2023-02-15 23:53:38 +02:00
DWARF Support in Clang
----------------------
2023-02-13 18:29:16 +00:00
2021-11-09 09:35:25 -05:00
Floating Point Support in Clang
-------------------------------
2023-02-02 12:31:53 -08:00
- Add `` __builtin_elementwise_log `` builtin for floating point types only.
2023-02-07 11:26:08 -08:00
- Add `` __builtin_elementwise_log10 `` builtin for floating point types only.
- Add `` __builtin_elementwise_log2 `` builtin for floating point types only.
2023-03-09 11:31:31 -08:00
- Add `` __builtin_elementwise_exp `` builtin for floating point types only.
- Add `` __builtin_elementwise_exp2 `` builtin for floating point types only.
2023-03-15 11:09:25 +08:00
- Add `` __builtin_set_flt_rounds `` builtin for X86, x86_64, Arm and AArch64 only.
2021-11-09 09:35:25 -05:00
2020-02-13 22:46:33 +01:00
AST Matchers
------------
2023-03-01 11:51:46 -05:00
- Add `` coroutineBodyStmt `` matcher.
- The `` hasBody `` matcher now matches coroutine body nodes in
`` CoroutineBodyStmts `` .
2020-02-13 22:46:33 +01:00
clang-format
------------
2023-02-06 18:47:11 +08:00
- Add `` NextLineOnly `` style to option `` PackConstructorInitializers `` .
Compared to `` NextLine `` style, `` NextLineOnly `` style will not try to
put the initializers on the current line first, instead, it will try to
put the initializers on the next line only.
2023-03-27 15:16:11 +01:00
- Add additional Qualifier Ordering support for special cases such
as templates, requires clauses, long qualified names.
2023-04-05 14:28:56 -07:00
- Fix all known issues associated with `` LambdaBodyIndentation: OuterScope `` .
2023-04-29 00:22:22 -07:00
- Add `` BracedInitializerIndentWidth `` which can be used to configure
the indentation level of the contents of braced init lists.
2023-02-06 18:47:11 +08:00
2020-02-13 22:46:33 +01:00
libclang
--------
2022-08-25 08:35:46 +02:00
2023-02-09 09:53:10 -05:00
- Introduced the new function `` clang_CXXMethod_isExplicit `` ,
which identifies whether a constructor or conversion function cursor
was marked with the explicit identifier.
[libclang] Add API to override preamble storage path
TempPCHFile::create() calls llvm::sys::fs::createTemporaryFile() to
create a file named preamble-*.pch in a system temporary directory. This
commit allows overriding the directory where these often many and large
preamble-*.pch files are stored.
The referenced bug report requests the ability to override the temporary
directory path used by libclang. However, overriding the return value of
llvm::sys::path::system_temp_directory() was rejected during code review
as improper and because it would negatively affect multithreading
performance. Finding all places where libclang uses the temporary
directory is very difficult. Therefore this commit is limited to
override libclang's single known use of the temporary directory.
This commit allows to override the preamble storage path only during
CXIndex construction to avoid multithreading issues and ensure that all
preambles are stored in the same directory. For the same multithreading
and consistency reasons, this commit deprecates
clang_CXIndex_setGlobalOptions() and
clang_CXIndex_setInvocationEmissionPathOption() in favor of specifying
these options during CXIndex construction.
Adding a new CXIndex constructor function each time a new initialization
argument is needed leads to either a large number of function parameters
unneeded by most libclang users or to an exponential number of overloads
that support different usage requirements. Therefore this commit
introduces a new extensible struct CXIndexOptions and a general function
clang_createIndexWithOptions().
A libclang user passes a desired preamble storage path to
clang_createIndexWithOptions(), which stores it in
CIndexer::PreambleStoragePath. Whenever
clang_parseTranslationUnit_Impl() is called, it passes
CIndexer::PreambleStoragePath to ASTUnit::LoadFromCommandLine(), which
stores this argument in ASTUnit::PreambleStoragePath. Whenever
ASTUnit::getMainBufferWithPrecompiledPreamble() is called, it passes
ASTUnit::PreambleStoragePath to PrecompiledPreamble::Build().
PrecompiledPreamble::Build() forwards the corresponding StoragePath
argument to TempPCHFile::create(). If StoragePath is not empty,
TempPCHFile::create() stores the preamble-*.pch file in the directory at
the specified path rather than in the system temporary directory.
The analysis below proves that this passing around of the
PreambleStoragePath string is sufficient to guarantee that the libclang
user override is used in TempPCHFile::create(). The analysis ignores API
uses in test code.
TempPCHFile::create() is called only in PrecompiledPreamble::Build().
PrecompiledPreamble::Build() is called only in two places: one in
clangd, which is not used by libclang, and one in
ASTUnit::getMainBufferWithPrecompiledPreamble().
ASTUnit::getMainBufferWithPrecompiledPreamble() is called in 3 places:
ASTUnit::LoadFromCompilerInvocation() [analyzed below].
ASTUnit::Reparse(), which in turn is called only from
clang_reparseTranslationUnit_Impl(), which in turn is called only from
clang_reparseTranslationUnit(). clang_reparseTranslationUnit() is never
called in LLVM code, but is part of public libclang API. This function's
documentation requires its translation unit argument to have been built
with clang_createTranslationUnitFromSourceFile().
clang_createTranslationUnitFromSourceFile() delegates its work to
clang_parseTranslationUnit(), which delegates to
clang_parseTranslationUnit2(), which delegates to
clang_parseTranslationUnit2FullArgv(), which delegates to
clang_parseTranslationUnit_Impl(), which passes
CIndexer::PreambleStoragePath to the ASTUnit it creates.
ASTUnit::CodeComplete() passes AllowRebuild = false to
ASTUnit::getMainBufferWithPrecompiledPreamble(), which makes it return
nullptr before calling PrecompiledPreamble::Build().
Both ASTUnit::LoadFromCompilerInvocation() overloads (one of which
delegates its work to another) call
ASTUnit::getMainBufferWithPrecompiledPreamble() only if their argument
PrecompilePreambleAfterNParses > 0. LoadFromCompilerInvocation() is
called in:
ASTBuilderAction::runInvocation() keeps the default parameter value
of PrecompilePreambleAfterNParses = 0, meaning that the preamble file is
never created from here.
ASTUnit::LoadFromCommandLine().
ASTUnit::LoadFromCommandLine() is called in two places:
CrossTranslationUnitContext::ASTLoader::loadFromSource() keeps the
default parameter value of PrecompilePreambleAfterNParses = 0, meaning
that the preamble file is never created from here.
clang_parseTranslationUnit_Impl(), which passes
CIndexer::PreambleStoragePath to the ASTUnit it creates.
Therefore, the overridden preamble storage path is always used in
TempPCHFile::create().
TempPCHFile::create() uses PreambleStoragePath in the same way as
LibclangInvocationReporter() uses InvocationEmissionPath. The existing
documentation for clang_CXIndex_setInvocationEmissionPathOption() does
not specify ownership, encoding, separator or relative vs absolute path
requirements. So the documentation for
CXIndexOptions::PreambleStoragePath doesn't either. The assumptions are:
no ownership transfer;
UTF-8 encoding;
native separators.
Both relative and absolute paths are supported.
The added API works as expected in KDevelop:
https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/283
Fixes: https://github.com/llvm/llvm-project/issues/51847
Differential Revision: https://reviews.llvm.org/D143418
2023-03-07 08:24:23 -05:00
- Introduced the new `` CXIndex `` constructor function
2023-03-15 09:21:41 -04:00
`` clang_createIndexWithOptions `` , which allows storing precompiled preambles
in memory or overriding the precompiled preamble storage path.
[libclang] Add API to override preamble storage path
TempPCHFile::create() calls llvm::sys::fs::createTemporaryFile() to
create a file named preamble-*.pch in a system temporary directory. This
commit allows overriding the directory where these often many and large
preamble-*.pch files are stored.
The referenced bug report requests the ability to override the temporary
directory path used by libclang. However, overriding the return value of
llvm::sys::path::system_temp_directory() was rejected during code review
as improper and because it would negatively affect multithreading
performance. Finding all places where libclang uses the temporary
directory is very difficult. Therefore this commit is limited to
override libclang's single known use of the temporary directory.
This commit allows to override the preamble storage path only during
CXIndex construction to avoid multithreading issues and ensure that all
preambles are stored in the same directory. For the same multithreading
and consistency reasons, this commit deprecates
clang_CXIndex_setGlobalOptions() and
clang_CXIndex_setInvocationEmissionPathOption() in favor of specifying
these options during CXIndex construction.
Adding a new CXIndex constructor function each time a new initialization
argument is needed leads to either a large number of function parameters
unneeded by most libclang users or to an exponential number of overloads
that support different usage requirements. Therefore this commit
introduces a new extensible struct CXIndexOptions and a general function
clang_createIndexWithOptions().
A libclang user passes a desired preamble storage path to
clang_createIndexWithOptions(), which stores it in
CIndexer::PreambleStoragePath. Whenever
clang_parseTranslationUnit_Impl() is called, it passes
CIndexer::PreambleStoragePath to ASTUnit::LoadFromCommandLine(), which
stores this argument in ASTUnit::PreambleStoragePath. Whenever
ASTUnit::getMainBufferWithPrecompiledPreamble() is called, it passes
ASTUnit::PreambleStoragePath to PrecompiledPreamble::Build().
PrecompiledPreamble::Build() forwards the corresponding StoragePath
argument to TempPCHFile::create(). If StoragePath is not empty,
TempPCHFile::create() stores the preamble-*.pch file in the directory at
the specified path rather than in the system temporary directory.
The analysis below proves that this passing around of the
PreambleStoragePath string is sufficient to guarantee that the libclang
user override is used in TempPCHFile::create(). The analysis ignores API
uses in test code.
TempPCHFile::create() is called only in PrecompiledPreamble::Build().
PrecompiledPreamble::Build() is called only in two places: one in
clangd, which is not used by libclang, and one in
ASTUnit::getMainBufferWithPrecompiledPreamble().
ASTUnit::getMainBufferWithPrecompiledPreamble() is called in 3 places:
ASTUnit::LoadFromCompilerInvocation() [analyzed below].
ASTUnit::Reparse(), which in turn is called only from
clang_reparseTranslationUnit_Impl(), which in turn is called only from
clang_reparseTranslationUnit(). clang_reparseTranslationUnit() is never
called in LLVM code, but is part of public libclang API. This function's
documentation requires its translation unit argument to have been built
with clang_createTranslationUnitFromSourceFile().
clang_createTranslationUnitFromSourceFile() delegates its work to
clang_parseTranslationUnit(), which delegates to
clang_parseTranslationUnit2(), which delegates to
clang_parseTranslationUnit2FullArgv(), which delegates to
clang_parseTranslationUnit_Impl(), which passes
CIndexer::PreambleStoragePath to the ASTUnit it creates.
ASTUnit::CodeComplete() passes AllowRebuild = false to
ASTUnit::getMainBufferWithPrecompiledPreamble(), which makes it return
nullptr before calling PrecompiledPreamble::Build().
Both ASTUnit::LoadFromCompilerInvocation() overloads (one of which
delegates its work to another) call
ASTUnit::getMainBufferWithPrecompiledPreamble() only if their argument
PrecompilePreambleAfterNParses > 0. LoadFromCompilerInvocation() is
called in:
ASTBuilderAction::runInvocation() keeps the default parameter value
of PrecompilePreambleAfterNParses = 0, meaning that the preamble file is
never created from here.
ASTUnit::LoadFromCommandLine().
ASTUnit::LoadFromCommandLine() is called in two places:
CrossTranslationUnitContext::ASTLoader::loadFromSource() keeps the
default parameter value of PrecompilePreambleAfterNParses = 0, meaning
that the preamble file is never created from here.
clang_parseTranslationUnit_Impl(), which passes
CIndexer::PreambleStoragePath to the ASTUnit it creates.
Therefore, the overridden preamble storage path is always used in
TempPCHFile::create().
TempPCHFile::create() uses PreambleStoragePath in the same way as
LibclangInvocationReporter() uses InvocationEmissionPath. The existing
documentation for clang_CXIndex_setInvocationEmissionPathOption() does
not specify ownership, encoding, separator or relative vs absolute path
requirements. So the documentation for
CXIndexOptions::PreambleStoragePath doesn't either. The assumptions are:
no ownership transfer;
UTF-8 encoding;
native separators.
Both relative and absolute paths are supported.
The added API works as expected in KDevelop:
https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/283
Fixes: https://github.com/llvm/llvm-project/issues/51847
Differential Revision: https://reviews.llvm.org/D143418
2023-03-07 08:24:23 -05:00
- Deprecated two functions `` clang_CXIndex_setGlobalOptions `` and
`` clang_CXIndex_setInvocationEmissionPathOption `` in favor of the new
function `` clang_createIndexWithOptions `` in order to improve thread safety.
2023-03-14 09:57:44 -04:00
- Added check in `` clang_getFieldDeclBitWidth `` for whether a bit-field
has an evaluable bit width. Fixes undefined behavior when called on a
bit-field whose width depends on a template paramter.
2020-02-13 22:46:33 +01:00
Static Analyzer
---------------
2023-02-28 16:42:32 -08:00
- Fix incorrect alignment attribute on the this parameter of certain
non-complete destructors when using the Microsoft ABI.
2023-03-11 18:39:33 +02:00
(`#60465 <https://github.com/llvm/llvm-project/issues/60465> `_ )
[analyzer] Consider single-elem arrays as FAMs by default
According to my measurement in https://reviews.llvm.org/D108230#3933232,
it seems like there is no drawback to enabling this analyzer-config by default.
Actually, enabling this by default would make it consistent with the
codegen of clang, which according to `-fstrict-flex-arrays`, assumes
by default that all trailing arrays could be FAMs, let them be of size
undefined, zero, one, or anything else.
Speaking of `-fstrict-flex-arrays`, in the next patch I'll deprecate
the analyzer-config FAM option in favor of that flag. That way, CSA will
always be in sync with what the codegen will think of FAMs.
So, if a new codebase sets `-fstrict-flex-arrays` to some value above 0,
CSA will also make sure that only arrays of the right size will be
considered as FAMs.
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D138657
2022-11-25 10:24:56 +01:00
2022-09-26 17:41:37 -07:00
.. _release-notes-sanitizers:
Sanitizers
----------
2020-02-13 22:46:33 +01:00
2023-04-04 09:21:04 -04:00
Python Binding Changes
----------------------
The following methods have been added:
- `` clang_Location_isInSystemHeader `` exposed via the `` is_in_system_header ``
property of the `Location` class.
2020-02-13 22:46:33 +01:00
Additional Information
======================
A wide variety of additional information is available on the `Clang web
page <https://clang.llvm.org/>`_. The web page contains versions of the
2020-03-22 22:18:40 +01:00
API documentation which are up-to-date with the Git version of
2020-02-13 22:46:33 +01:00
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
2023-02-15 23:53:38 +02:00
contact us on the `Discourse forums (Clang Frontend category)
2022-07-01 14:07:48 -07:00
<https://discourse.llvm.org/c/clang/6> `_.