Extra Clang Tools 22.1.8 Release Notes — Extra Clang Tools 22.1.8 documentation

# Extra Clang Tools 22.1.8 documentation

## Extra Clang Tools 22.1.8 Release Notes

Written by the LLVM Team

## Introduction

This document contains the release notes for the Extra Clang Tools, part of the Clang release 22.1.8. 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 22.1.8?

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

- Deprecated the clang-tidy `hicpp` module. All checks have been moved to other modules instead. The `hicpp` module will be removed for the 23.x release.

- Deprecated the clang-tidy `zircon` module. All checks have been moved to the `fuchsia` module instead. The `zircon` module will be removed in the 24th release.

- Removed clang-tidy’s global options IgnoreMacros and StrictMode, which were documented as deprecated since clang-tidy-20. Users should use the check-specific options of the same name instead.

- Removed clang-analyzer-* checks from default checks in clang-tidy. From now on, users should specify explicitly that they want CSA checks to run in clang-tidy via clang-analyzer-*.

- Renamed a few clang-tidy check options, as they were misspelled:

  - NamePrefixSuffixSilenceDissimilarityTreshold to NamePrefixSuffixSilenceDissimilarityThreshold in bugprone-easily-swappable-parameters

  - CharTypdefsToIgnore to CharTypedefsToIgnore in bugprone-signed-char-misuse

- Modified the custom message format of bugprone-unsafe-functions by assigning a special meaning to the character `>` at the start of the value of the option `CustomFunctions`. If the option value starts with `>`, then the replacement suggestion part of the message (which would be included by default) is omitted. (This does not change the warning locations.)

- clang-tidy now displays warnings from all non-system headers by default. Previously, users had to explicitly opt-in to header warnings using -header-filter=’.*’. To disable warnings from non-system, set -header-filter to an empty string.

- The `clang-tidy/ClangTidyModuleRegistry.h` header has been deprecated and will be removed in LLVM 24. All of the symbols it used to define have been moved into `clang-tidy/ClangTidyModule.h`.

### Improvements to clangd

#### Compile flags

- Added proper support for the `-std=c++latest` flag, often used by Windows users writing C++23 code.

#### Diagnostics

- Fixed a bug that caused the quick-fix for the `readability-identifier-naming` diagnostic not to work in some editors.

#### Hover

- Added support for parsing and presenting doxygen and markdown documentation

- Added a `MacroContentsLimit` config option to allow users to opt into showing macro definitions in hovers even if they’re very long

- Fixed a bug that prevented documentation from being shown for members of class templates defined in a header

- Fixed a bug that prevented documentation from being shown for abbreviated function templates

#### Cross-references

- Improved “go to definition” support for dependent `auto`

- Improved “go to definition” support for C++23 “deducing this”

- Fixed a bug where attributes on a method broke various features including “go to definition” on a method’s name

- “Find references” on a constructor now finds call sites of forwarding functions such as `make_unique` as well

- “Document links” now supports `#include` directives with a macro argument

#### Inlay hints

- Show designator hints for aggregate initialization of structures with parentheses-list initialization (`CXXParenListInitExpr`) syntax.

- Show type hints for simple cases of dependent `auto`

#### Call hierarchy

- Support invoking call hierarchy on enum constants

- When invoked on a virtual function, show callers of base functions as well

#### Document symbols

- Include inline friend functions in document symbols

#### Code folding

- Support folding of preprocessor branches

- Support folding of `#pragma region` blocks

#### Code completion

- Added a new `MacroFilter` configuration option to `Completion` to allow fuzzy-matching with the `FuzzyMatch` option when suggesting macros. `ExactPrefix` is the default, which retains previous behavior of suggesting macros which match the prefix exactly.

- Improved support for C++23 “deducing this”

- Header insertion now checks `AngledHeaders` and `QuotedHeaders` against resolved rather than spelled paths, consistent with the existing behaviour of include-cleaner diagnostics.

#### Code actions

- New `Override pure virtual methods` code action. When invoked on a class definition, this action automatically generates C++ `override` declarations for all pure virtual methods inherited from its base classes that have not yet been implemented. The generated method stubs prompts the user for the actual implementation. The overrides are intelligently grouped under their original access specifiers (e.g., `public`, `protected`), creating new access specifier blocks if necessary.

- Improved the “move function body out-of-line” code action’s logic for choosing where to place the definition. It now tries to place it next to the definition of a method with an adjacent declaration.

#### C++20 Modules support

- Fixed a crash when using `--experimental-modules-support` without a compilation database

- Added a `--debug-modules-builder` option to help debug clangd’s modules support

- Improved diagnostics related to modules

- Clangd now tries to reuse a module from the project’s build if it’s suitable

#### Miscellaneous

- Add wildcard `.gitignore` file to the clangd index directory.

### Improvements to clang-doc

- Use the Mustache HTML generator as the default HTML option.

- Document concepts, typedefs, aliases, public class members, nested records, nested namespaces, global functions, global variables, protected methods and members and friends in HTML.

- Document `throws` comments in HTML.

- Add definition location for classes in HTML.

- Show class template declaration in HTML.

- Add a top-level index page in HTML. This page lists the top-level namespaces and serves as the documentation’s root URL.

- Add a `Home` button to the navigation bar which replaces non-useful buttons. This new button links to the top-level index page.

- Add a breadcrumb navigation bar to the navbar. This helps navigate through a documented entity’s context.

- If a filename is too long, then the name will be truncated and the documented entity’s USR will be concatenated to guarantee its uniqueness.

- Revert the flat directory structure to a nested directory structure.

### Improvements to clang-query

- Matcher queries interpreted by clang-query are now support trailing comma (,) in matcher arguments. Note that C++ still doesn’t allow this in function arguments. So when porting a query to C++, remove all instances of trailing comma (otherwise C++ compiler will just complain about “expected expression”).

### Improvements to clang-tidy

- The check_clang_tidy.py tool now recognizes the `-std` argument when run over C files. If `-std` is not specified, it defaults to `c99-or-later`.

- clang-tidy now displays warnings from all non-system headers by default. Previously, users had to explicitly opt-in to header warnings using -header-filter=’.*’. To disable warnings from non-system, set -header-filter to an empty string.

- clang-tidy no longer attempts to analyze code from system headers by default, greatly improving performance. This behavior is disabled if the SystemHeaders option is enabled.

- clang-tidy now supports query based custom checks by CustomChecks configuration option. Query Based Custom Check Document

- The run-clang-tidy.py and clang-tidy-diff.py scripts now run checks in parallel by default using all available hardware threads. Both scripts display the number of threads being used in their output.

- Improved run-clang-tidy.py by adding a new option enable-check-profile to enable per-check timing profiles and print a report based on all analyzed files.

- Improved documentation of the -line-filter command-line flag of clang-tidy and run-clang-tidy.py.

- Improved clang-tidy option -quiet by suppressing diagnostic count messages.

- Improved clang-tidy by not crashing when an empty directory field is used in a compilation database; the current working directory will be used instead, and an error message will be printed.

- Removed clang-tidy’s global options IgnoreMacros and StrictMode, which were documented as deprecated since clang-tidy-20. Users should use the check-specific options of the same name instead.

- Improved run-clang-tidy.py and clang-tidy-diff.py scripts by adding the -hide-progress option to suppress progress and informational messages.

- Removed clang-analyzer-* check from default checks in clang-tidy. From now on, users should specify explicitly that they want CSA checks to run in clang-tidy.

- Improved clang-tidy by adding the –removed-arg option to remove arguments sent to the compiler when invoking Clang-Tidy. This option was also added to run-clang-tidy.py and clang-tidy-diff.py and can be configured in the config file through the RemovedArgs option.

- Deprecated the clang-tidy `zircon` module. All checks have been moved to the `fuchsia` module instead. The `zircon` module will be removed in the 24th release.

- Improved clang-tidy configuration parsing by allowing the same list syntax in WarningsAsErrors as in Checks.

#### New checks

- New abseil-unchecked-statusor-access check.

  Finds uses of `absl::StatusOr` without checking if a value is present.

- New bugprone-derived-method-shadowing-base-method check.

  Finds derived class methods that shadow a (non-virtual) base class method.

- New bugprone-invalid-enum-default-initialization check.

  Detects default initialization (to 0) of variables with `enum` type where the enum has no enumerator with value of 0.

- New cppcoreguidelines-pro-bounds-avoid-unchecked-container-access check.

  Finds calls to `operator[]` in STL containers and suggests replacing them with safe alternatives.

- New google-runtime-float check.

  Finds uses of `long double` and suggests against their use due to lack of portability.

- New llvm-mlir-op-builder check.

  Checks for uses of MLIR’s old/to be deprecated `OpBuilder::create<T>` form and suggests using `T::create` instead.

- New llvm-use-ranges check.

  Finds calls to STL library iterator algorithms that could be replaced with LLVM range-based algorithms from `llvm/ADT/STLExtras.h`.

- New misc-override-with-different-visibility check.

  Finds virtual function overrides with different visibility than the function in the base class.

- New readability-inconsistent-ifelse-braces check.

  Detects `if`/`else` statements where one branch uses braces and the other does not.

- New readability-redundant-parentheses check.

  Detect redundant parentheses.

- New readability-redundant-typename check.

  Finds redundant uses of the `typename` keyword.

#### New check aliases

- Renamed cert-dcl50-cpp to modernize-avoid-variadic-functions keeping initial check as an alias to the new one.

- Renamed cert-dcl58-cpp to bugprone-std-namespace-modification keeping initial check as an alias to the new one.

- Renamed cert-env33-c to bugprone-command-processor keeping initial check as an alias to the new one.

- Renamed cert-err34-c to bugprone-unchecked-string-to-number-conversion keeping initial check as an alias to the new one.

- Renamed cert-err52-cpp to modernize-avoid-setjmp-longjmp keeping initial check as an alias to the new one.

- Renamed cert-err58-cpp to bugprone-throwing-static-initialization keeping initial check as an alias to the new one.

- Renamed cert-err60-cpp to bugprone-exception-copy-constructor-throws

- Renamed cert-flp30-c to bugprone-float-loop-counter keeping initial check as an alias to the new one.

- Renamed cert-mem57-cpp to bugprone-default-operator-new-on-overaligned-type keeping initial check as an alias to the new one.

- Renamed cert-msc30-c to misc-predictable-rand keeping initial check as an alias to the new one.

- Renamed cert-msc32-c to bugprone-random-generator-seed keeping initial check as an alias to the new one.

- Renamed cert-msc50-cpp to misc-predictable-rand keeping initial check as an alias to the new one.

- Renamed cert-msc51-cpp to bugprone-random-generator-seed keeping initial check as an alias to the new one.

- Renamed cert-oop57-cpp to bugprone-raw-memory-call-on-non-trivial-type keeping initial check as an alias to the new one.

- Renamed cert-oop58-cpp to bugprone-copy-constructor-mutates-argument keeping initial check as an alias to the new one.

- Renamed fuchsia-multiple-inheritance to misc-multiple-inheritance keeping initial check as an alias to the new one.

- Renamed google-build-namespaces to misc-anonymous-namespace-in-header keeping initial check as an alias to the new one.

- Renamed google-readability-casting to modernize-avoid-c-style-cast keeping initial check as an alias to the new one.

#### Changes in existing checks

- Improved bugprone-chained-comparison check by adding a new option IgnoreMacros to suppress warnings within macro expansions.

- Improved bugprone-dynamic-static-initializers check:

  - Avoided false positives for `constexpr` variables whose initializers are value-dependent.

  - Added support for C++20 `constinit` variables.

- Improved bugprone-easily-swappable-parameters check by correcting a spelling mistake on its option `NamePrefixSuffixSilenceDissimilarityTreshold`.

- Improved bugprone-exception-escape check:

  - Exceptions from lambda captures are now diagnosed, exceptions in the bodies of lambdas that aren’t actually invoked are not.

  - Fixed an issue where the check wouldn’t diagnose throws in arguments to functions or constructors.

  - Added fine-grained configuration via options CheckDestructors, CheckMoveMemberFunctions, CheckMain, CheckedSwapFunctions, and CheckNothrowFunctions.

- Improved bugprone-infinite-loop check by adding detection for variables introduced by structured bindings.

- Improved bugprone-invalid-enum-default-initialization with new IgnoredEnums option to ignore specified enums during analysis.

- Improved bugprone-macro-parentheses check by fixing false positives when using C++ template parameters.

- Improved bugprone-narrowing-conversions check by fixing false positive from analysis of a conditional expression in C.

- Improved bugprone-not-null-terminated-result check by fixing bogus fix-its for `strncmp` and `wcsncmp` on Windows and a crash caused by certain value-dependent expressions.

- Improved bugprone-reserved-identifier check by ignoring declarations and macros in system headers.

- Improved bugprone-signed-char-misuse check by fixing false positives on C23 enums with the fixed underlying type of signed char.

- Improved bugprone-sizeof-expression check by fixing a crash on `sizeof` of an array of dependent type.

- Improved bugprone-suspicious-include check by adding IgnoredRegex option.

- Improved bugprone-tagged-union-member-count by fixing a false positive when enums or unions from system header files or the `std` namespace are treated as the tag or the data part of a user-defined tagged union respectively.

- Improved bugprone-throw-keyword-missing check:

  - Now it only considers the canonical types of base classes as written.

  - Added a note on the base class that triggered the warning.

  - Fixed an issue where the check wouldn’t fire in constructors or (in certain contexts) lambdas.

- Improved bugprone-unchecked-optional-access check:

  - Added support for `NullableValue::makeValue` and `NullableValue::makeValueInplace` to prevent false-positives for `BloombergLP::bdlb::NullableValue`.

  - Fixed false-positives for `bsl::optional` containing allocator-aware type.

  - Added the IgnoreValueCalls option to suppress diagnostics for `optional::value()`.

  - Added the IgnoreSmartPointerDereference option to ignore optionals reached via smart-pointer-like dereference, while still diagnosing UB-prone dereferences via `operator*` and `operator->`.

- Improved bugprone-unhandled-self-assignment check by adding an additional matcher that generalizes the copy-and-swap idiom pattern detection.

- Improved bugprone-unsafe-functions check by hiding the default suffix when the reason starts with the character > in the CustomFunctions option.

- Improved bugprone-use-after-move check:

  - Added InvalidationFunctions option to support custom invalidation functions.

  - Added ReinitializationFunctions option to support custom reinitialization functions.

- Improved cppcoreguidelines-avoid-non-const-global-variables check by adding a new option AllowThreadLocal that suppresses warnings on non-const global variables with thread-local storage duration.

- Improved cppcoreguidelines-init-variables check by fixing the insertion location for function pointers with multiple parameters.

- Improved cppcoreguidelines-macro-usage check by excluding macro bodies that starts with `__attribute__((..))` keyword. Such a macro body is unlikely a proper expression and so suggesting users an impossible rewrite into a template function should be avoided.

- Improved cppcoreguidelines-prefer-member-initializer check to avoid false positives on inherited members in class templates.

- Improved cppcoreguidelines-pro-bounds-pointer-arithmetic check adding AllowIncrementDecrementOperators option to allow pointer arithmetic via prefix/postfix increment or decrement operators.

- Improved cppcoreguidelines-pro-type-member-init check to correctly ignore `std::array` and other array-like containers when IgnoreArrays option is set to true.

- Improved fuchsia-multiple-inheritance by fixing an issue where the check would only analyze the first class with a given name in the program, missing any subsequent classes with that same name (declared in a different scope).

- Improved google-readability-casting check by adding fix-it notes for downcasts and casts to void pointer.

- Improved google-readability-todo check to accept the new TODO format from the Google Style Guide.

- Improved llvm-prefer-isa-or-dyn-cast-in-conditionals check:

  - Fix-it handles callees with nested-name-specifier correctly.

  - `if` statements with init-statement (`if (auto X = ...; ...)`) are handled correctly.

  - `for` loops are supported.

- Improved misc-const-correctness check:

  - Fixed false positives when pointers is transferred to non-const references.

  - Fixed false positives of function pointer, on return of non-const pointer, on pointer-to-member operator.

  - Fixed false positives when the address of a variable is taken to be passed to a function.

- Improved misc-coroutine-hostile-raii check by adding the option AllowedCallees, that allows exempting safely awaitable callees from the check.

- Improved misc-header-include-cycle check performance.

- Improved misc-use-internal-linkage check:

  - Added suggestion of internal linkage for user-defined types (structs, classes, unions, and enums).

  - Added fine-grained options AnalyzeFunctions, AnalyzeVariables, AnalyzeTypes to control whether the check should diagnose functions, variables, and/or user-defined types.

  - Enabled the check for C.

- Improved modernize-avoid-c-arrays to not diagnose array types which are part of an implicit instantiation of a template.

- Improved modernize-use-constraints check by fixing a crash on uses of non-standard `enable_if` with a signature different from `std::enable_if` (such as `boost::enable_if`).

- Improved modernize-use-default-member-init check to enhance the robustness of the member initializer detection.

- Improved modernize-use-designated-initializers check to suggest using designated initializers for aliased aggregate types.

- Improved modernize-use-integer-sign-comparison by providing correct fix-its when the right-hand side of a comparison contains a non-C-style cast.

- Improved modernize-use-nullptr check by fixing a crash on Windows when the check was enabled with a 32-bit clang-tidy binary.

- Improved modernize-use-override by fixing an issue where the check would sometimes suggest inserting `override` in an invalid place.

- Improved modernize-use-ranges check to suggest using the more idiomatic `std::views::reverse` where it used to suggest `std::ranges::reverse_view`.

- Improved modernize-use-scoped-lock check by fixing a crash on malformed code (common when using clang-tidy through clangd).

- Improved modernize-use-std-format check to correctly match when the format string is converted to a different type by an implicit constructor call.

- Improved modernize-use-std-print check to correctly match when the format string is converted to a different type by an implicit constructor call, and fixed a crash when handling format strings containing non-ASCII characters.

- Improved modernize-use-using check to correctly provide fix-its for typedefs of pointers or references to array types.

- Improved performance-move-const-arg check by avoiding false positives on trivially copyable types with a non-public copy constructor.

- Improved performance-unnecessary-copy-initialization by printing the type of the diagnosed variable.

- Improved performance-unnecessary-value-param by printing the type of the diagnosed variable and correctly generating fix-it hints for parameter-pack arguments.

- Improved portability-template-virtual-member-function check to avoid false positives on pure virtual member functions.

- Improved readability-container-contains to support string comparisons to `npos`. Internal changes may cause new rare false positives in non-standard containers.

- Improved readability-container-data-pointer check by correctly adding parentheses when the container expression is a dereference.

- Improved readability-container-size-empty check by correctly generating fix-it hints when size method is called from implicit `this`, ignoring default constructors with user provided arguments and adding detection in container’s method except `empty`.

- Improved readability-duplicate-include check by adding the `IgnoredFilesList` option (semicolon-separated list of regexes or filenames) to allow intentional duplicates.

- Improved readability-identifier-naming check:

  - Now ignores declarations and macros in system headers.

  - The documentation is improved to differentiate the general options from the specific ones.

  - Options for fine-grained control over `constexpr` variables were added.

  - Added default options which simplify configs by removing the need to specify each identifier kind separately.

- Improved readability-implicit-bool-conversion check:

  - Now correctly adds parentheses when inner expressions are implicitly converted multiple times.

  - Enabled the check for C99 and later standards.

  - Now allows implicit conversions from `bool` to integer when used as operands of logical operators (`&&`, `||`) in C.

- Improved readability-inconsistent-declaration-parameter-name check by not enforcing parameter name consistency between a variadic parameter pack in the primary template and specific parameters in its specializations.

- Improved readability-math-missing-parentheses check by correctly diagnosing operator precedence issues inside parenthesized expressions.

- Improved readability-qualified-auto check by adding the option IgnoreAliasing, that allows not looking at underlying types of type aliases.

- Improved readability-redundant-casting check by fixing false negatives when explicitly cast from function pointer.

- Improved readability-redundant-control-flow by fixing an issue where the check would sometimes suggest deleting not only a redundant `return` or `continue`, but also unrelated lines preceding it.

- Improved readability-uppercase-literal-suffix check to recognize literal suffixes added in C++23 and C23.

- Improved readability-use-concise-preprocessor-directives check to generate correct fix-its for forms without a space after the directive.

- Improved readability-use-std-min-max check by ensuring that comments between the `if` condition and the `then` block are preserved when applying the fix.

#### Removed checks

#### Miscellaneous

### Improvements to include-fixer

The improvements are…

### Improvements to clang-include-fixer

The improvements are…

### Improvements to modularize

The improvements are…

### Improvements to pp-trace

### Clang-tidy Visual Studio plugin