Extra Clang Tools 24.0.0git (In-Progress) Release Notes#
Written by the LLVM Team
Warning
These are in-progress notes for the upcoming Extra Clang Tools 24 release. Release notes for previous releases can be found on the Download Page.
Introduction#
This document contains the release notes for the Extra Clang Tools, part of the Clang release 24.0.0git. Here we describe the status of the Extra Clang Tools in some detail, including major improvements from the previous release and new feature work. 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.
Note that if you are reading this file from a Git checkout or the main Clang web page, this document applies to the next release, not the current one. To see the release notes for a specific release, please see the releases page.
What’s New in Extra Clang Tools 24.0.0git?#
Some of the major new features and improvements to Extra Clang Tools are listed here. Generic improvements to Extra Clang Tools as a whole or to its underlying infrastructure are described first, followed by tool-specific sections.
Major New Features#
Potentially Breaking Changes#
The deprecated
zirconclang-tidy module has been removed. Users ofzircon-temporary-objectsshould migrate to fuchsia-temporary-objects.In 22nd release, The
clang-tidy/ClangTidyModuleRegistry.hheader was deprecated. All of the symbols it used to define were moved intoclang-tidy/ClangTidyModule.h. The deprecated header has been removed in this release.
Improvements to clangd#
Inlay hints#
Diagnostics#
Query-based custom clang-tidy checks can now be enabled with the
Diagnostics.ClangTidy.ExperimentalCustomChecksclangd configuration option. Custom checks are subject toFastCheckFilter, and therefore requireFastCheckFilter: LooseorNoneto run.
Semantic Highlighting#
Compile flags#
Hover#
The type a
decltyperesolves to is now also shown for composite types, e.g.decltype(x)&is displayed asint&. Qualifiers applied to adecltypeare no longer dropped, soconst decltype(x)is displayed asconst intrather thanint.
Code completion#
Parameters declared with a
decltypeare now displayed as the type thedecltyperesolves to, e.g.set_x(int val)rather thanset_x(decltype(x) val).
Code actions#
clangd now applies clang-tidy fix-it post-processing before exposing fixes.
The
Extract to functiontweak is now offered for selections consisting of a single expression-statement (e.g. a lone function call or an overloaded operator call such asstream << 42;), which it previously refused to extract.The
Extract to functiontweak is now also available in C files, where it previously always refused to apply. Captured variables are passed by value when possible, and otherwise via a pointer parameter, since C has no references.
Signature help#
Parameters declared with a
decltypeare now displayed as the type thedecltyperesolves to, as for code completion.
Cross-references#
Objective-C#
Miscellaneous#
Fixed
clangd-indexer --format=yamlemitting invalid YAML when indexing C++20 concepts. (#206875)clangd-indexernow reads clangd configuration files (.clangdand the user config) by default. Pass--enable-config=falseto restore the previous behavior.Added support for loading dynamic plugins via the
-loadcommand-line option.
Improvements to clang-doc#
Improvements to clang-query#
Improvements to clang-tidy#
Improved check_clang_tidy.py by adding support of
-std=cXX-or-earliervalues, mirroring the existing-std=cXX-or-later. New construct expands to the given standard and every earlier one.On Windows, clang-tidy will now better match mixes of forwards and backwards slashes when using the
--line-filteroption. This also improves piping from git to clang-tidy-diff.py, where slashes will now be automatically normalized.
New checks#
New llvm-invalid-regex-pattern check.
Detects malformed regex patterns defined in a single string literal.
New modernize-use-if-consteval check.
Replaces direct
std::is_constant_evaluated()checks inifstatements with C++23’sif constevalsyntax.New modernize-use-to-underlying check.
Finds casts from a scoped enumeration (
enum class) to an integer type and replaces them with a call tostd::to_underlying(introduced in C++23).New performance-expensive-value-or check.
Finds calls to
value_or(and alternative spellingsvalueOr,ValueOr) on optional types where the return type is expensive to copy.New portability-avoid-pragma-comment check.
Finds uses of
#pragma commentand, forliborlinkercomments, suggests using the build system for improved portability.New readability-redundant-zero-initializer check.
Finds explicit zero initializers of arrays that can be replaced with empty braces.
New check aliases#
Changes in existing checks#
Improved bugprone-assignment-in-if-condition check by ignoring assignments inside GNU statement expressions unless they form the value of the statement expression.
Improved bugprone-easily-swappable-parameters check by no longer emitting empty notes for type aliases when
ModelImplicitConversionsis enabled.Improved bugprone-implicit-widening-of-multiplication-result check by suggesting a wider type of the same signedness as the original operands, instead of forcing a signed type, when a multiplication of two unsigned operands narrower than
intis only signed due to integer promotion.Improved bugprone-macro-parentheses by fixing invalid fixes for macro arguments used as names in alias declarations.
Fixed a crash in bugprone-misplaced-operator-in-strlen-in-alloc when checking an array new expression without a size expression.
Fixed a crash in bugprone-misplaced-pointer-arithmetic-in-alloc when pointer arithmetic is applied to a non-array
newexpression whose constructor has no arguments.Fixed a crash in bugprone-pointer-arithmetic-on-polymorphic-object when the pointer points to an incomplete (forward-declared) type.
Improved bugprone-redundant-branch-condition check by fixing false positives when the condition variable is changed later in a loop that encloses the inner
if.Fixed a crash in bugprone-std-namespace-modification when checking lambda closure types used as template arguments.
Improved bugprone-unchecked-optional-access by fixing false positives on
bsl::optionalandbdlb::NullableValueconstructed from a value or returned bybsl::make_optional.Improved cppcoreguidelines-missing-std-forward check by diagnosing unforwarded
auto&¶meters in C++20 abbreviated function templates.Improved cppcoreguidelines-pro-type-member-init check by treating
std::arraythe same as built-in arrays whenIgnoreArraysoption is enabled.Improved cppcoreguidelines-use-enum-class check by omitting unnamed enums from the
enum classrequirement, as previously the check suggested users an ill-formed fix.Improved cppcoreguidelines-virtual-class-destructor check by emitting the diagnostic and its fix-it notes at the destructor’s location instead of the class name, whenever the destructor is user-declared. The diagnostics are still emitted at the class name for implicitly declared destructors.
Improved misc-const-correctness check:
Fixed false positives when the pointee is written through a pointer that is incremented, decremented or adjusted with
+=or-=, such as*p++ = 0.Fixed false positives when the pointee is written through a pointer assignment, such as
*(p = q) = 0.No longer diagnoses variables declared with
decltype(auto), where the suggestedconstdoes not compile.No longer diagnoses parameters of
main, whose signature is fixed by the standard.
Fixed an infinite loop in misc-multiple-inheritance when checking a class that inherits from itself or has a circular inheritance graph.
Improved misc-redundant-expression by fixing false positives in nested expressions involving different macros or a mix of macro and non-macro operands.
Fixed a crash in modernize-raw-string-literal on synthetic string literals created for raw user-defined literal operators, such as
12_w.Improved modernize-return-braced-init-list check to no longer rewrite the return value when the constructed type has a
std::initializer_listconstructor, as the braced form could select a different constructor.Fixed a crash in modernize-use-designated-initializers when analyzing malformed code with nested classes and ambiguous initializer.
Improved modernize-use-equals-default check to also capture default constructor with explicit default-initialization of parents.
Fixed a crash in modernize-use-noexcept when analyzing malformed template code with an unparsed exception specification.
Extend modernize-use-nullptr to turn
decltype(nullptr)intostd::nullptr_tfrom<cstdef>.Improved modernize-use-nullptr check to avoid replacing
0withnullptrin comparisons with ordering types such asstd::strong_ordering.Improved modernize-use-ranges check by preserving used output iterator results when replacing output algorithms such as
std::copy.Preserved used callable results when replacing
std::for_eachand structured binding results when replacing algorithms such asstd::equal_range.Kept diagnostics but suppressed unsafe fix-its when no safe result-preserving rewrite is available.
Improved performance-inefficient-algorithm check to no longer produce a fix with the container or the searched-for value missing, such as
.find(43)ors.find(), when either comes from a macro. The value is copied as written rather than with its parentheses stripped, and no fix is offered when an argument covers only part of a macro expansion, as it then has no source text of its own.Improved performance-inefficient-vector-operation by adding the
ForRangeLoopClassesto configure container classes that can be used as sources in range-basedforloops.Improved performance-no-automatic-move check by no longer warning when returning a variable captured by a lambda or a block, which is never implicitly moved from.
Improved performance-prefer-single-char-overloads check to avoid offering fix-its for string literals originating from macro expansions.
Improved readability-convert-member-functions-to-static check by fixing a crash when checking a const-qualified method declared with the
lifetimeboundattribute.Improved readability-enum-initial-value check by adding the
AllowReferencedInitialValuesto support theINT09-C-EX1exception, allowing enumerators initialized by referencing another enumerator in the same enum (e.g.,last = first).Improved readability-function-cognitive-complexity check by fixing a crash when checking a function declared with the
aliasattribute.Improved readability-identifier-naming check:
Fixed a crash when a class inherits from a forward-declared base class.
Fixed a crash when checking forward-declared classes with
DefaultHungarianPrefixenabled.Fixed
DefaultHungarianPrefixbeing incorrectly diagnosed as an invalid option.Fixed invalid fixes when renaming parameter packs used in
sizeof...expressions.Added the
TypedefInheritAnonTagConfig, which checks a typedef or type alias that provides the only name of an otherwise unnamed tag, such astypedef enum {} MyEnum;, against the style configured for that tag kind instead of the typedef or type alias style.Added support for naming lambda init-captures (e.g.
[Captured = Var]) via the newLambdaCaptureoptions. Simple, non-init captures continue to follow the naming style of the variable they capture.Added the
AllowTrailingUnderscore, which permits a single trailing underscore on any identifier.
Improved readability-named-parameter check by ignoring standard tag types (e.g.
std::in_place_t,std::allocator_arg_t,std::nothrow_t, iterator tags, lock tags, etc.) that are used exclusively for overload resolution. Added theIgnoredTypesoption to allow customizing the set of ignored types.Improved readability-non-const-parameter check by fixing false positives on pointers passed to atomic builtins, whose operands may be written to, such as the
expectedparameter ofatomic_compare_exchange_strong().Improved readability-redundant-parentheses check:
Fixed a false positive on the required parentheses of
typeofandtypeof_unqualoperands.Fixed false positives and incorrect fixes caused by synthetic parentheses in reference non-type template parameter uses,
__builtin_dump_structcalls, and OpenMPlinearclauses.Fixed false positives on parentheses that determine the deduced type in
decltype((x))and in the initializers and return statements ofdecltype(auto)declarations.
Fixed readability-simplify-boolean-expr producing invalid fixes when applying De Morgan’s theorem to overloaded comparison operators.
Improved readability-suspicious-call-argument check by fixing the default
distanddstabbreviations ofdistancenot being recognized.Improved readability-trailing-comma check:
Fixed false positives on designated initializers, where initializer lists synthesized for intermediate subobjects caused the trailing comma of the enclosing list to be incorrectly rewritten.
Ignored preprocessor directives such as
#endifthat appear immediately before an enum’s closing brace, which previously produced a false positive and a fix-it that inserted a comma after the directive.Fixed a false positive on empty brace initializers of types with default member initializers.
Improved readability-use-std-min-max check by fixing spurious trailing semicolons and lost comments when the
ifbody has no braces.
Removed checks#
Removed the deprecated
zircon-temporary-objectscheck. Users should migrate to fuchsia-temporary-objects.
Miscellaneous#
Fixed clang-tidy adding an unwanted blank line when automatically inserting a missing
#include, which stopped clang-format and thellvm-include-ordercheck from being able to sort it correctly afterwards.