Extra Clang Tools 18.1.7 Release Notes

Written by the LLVM Team

Introduction

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

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

Improvements to clangd

Inlay hints

  • Type hints
    • Improved heuristics for showing sugared vs. desguared types

    • Some hints which provide no information (e.g. <dependent-type>) are now omitted

  • Parameter hints
    • Parameter hints are now shown for calls through function pointers

    • Parameter hints are now shown for calls to a class’s operator()

    • No longer show bogus parameter hints for some builtins like __builtin_dump_struct

Compile flags

  • System include extractor (--query-driver) improvements
    • The directory containing builtin headers is now excluded from extracted system includes

    • Various flags which can affect the system includes (--target, --stdlib, -specs) are now forwarded to the driver

    • Fixed a bug where clangd would sometimes try to call a driver that didn’t have obj-c support with -x objective-c++-header

    • The driver path is now dot-normalized before being compared to the --query-driver pattern

    • --query-driver is now supported by clangd-indexer

  • Fixed a regression in clangd 17 where response files would not be expanded

Hover

  • Hover now shows alignment info for fields and records

Code completion

  • Refined heuristics for determining whether the use of a function can be a call or not

Code actions

  • The extract variable tweak gained support for extracting lambda expressions to a variable.

  • A new tweak was added for turning unscoped into scoped enums.

Signature help

  • Improved support for calls through function pointer types

Cross-references

  • Improved support for C++20 concepts

  • Find-references now works for labels

  • Improvements to template heuristics

Objective-C

Miscellaneous

  • Various stability improvements, e.g. crash fixes

  • Improved error recovery on invalid code

  • Clangd now bails gracefully on assembly and IR source files

Improvements to clang-doc

Improvements to clang-query

The improvements are…

Improvements to clang-rename

The improvements are…

Improvements to clang-tidy

  • Preprocessor-level module header parsing is now disabled by default due to the problems it caused in C++20 and above, leading to performance and code parsing issues regardless of whether modules were used or not. This change will impact only the following checks: modernize-replace-disallow-copy-and-assign-macro, bugprone-reserved-identifier, and readability-identifier-naming. Those checks will no longer see macros defined in modules. Users can still enable this functionality using the newly added command line option –enable-module-headers-parsing.

  • Remove configuration option AnalyzeTemporaryDestructors, which was deprecated since clang-tidy 16.

  • Improved –dump-config to print check options in alphabetical order.

  • Improved clang-tidy-diff.py script.
    • Return exit code 1 if any clang-tidy subprocess exits with a non-zero code or if exporting fixes fails.

    • Accept a directory as a value for -export-fixes to export individual yaml files for each compilation unit.

    • Introduce a -config-file option that forwards a configuration file to clang-tidy. Corresponds to the –config-file option in clang-tidy.

  • Improved run-clang-tidy.py script. It now accepts a directory as a value for -export-fixes to export individual yaml files for each compilation unit.

New checks

New check aliases

Changes in existing checks

  • Improved abseil-string-find-startswith check to also consider std::basic_string_view in addition to std::basic_string by default.

  • Improved bugprone-assert-side-effect check to report usage of non-const << and >> operators in assertions and fixed some false-positives with const operators.

  • Improved bugprone-dangling-handle check to support functional casting during type conversions at variable initialization, now with improved compatibility for C++17 and later versions.

  • Improved bugprone-exception-escape check by extending the default check function names to include iter_swap and iter_move.

  • Improved bugprone-implicit-widening-of-multiplication-result check to correctly emit fixes.

  • Improved bugprone-lambda-function-name check by adding option IgnoreMacros to ignore warnings in macros.

  • Improved bugprone-non-zero-enum-to-bool-conversion check by eliminating false positives resulting from direct usage of bitwise operators.

  • Improved bugprone-reserved-identifier check, so that it does not warn on macros starting with underscore and lowercase letter.

  • Improved bugprone-sizeof-expression check diagnostics to precisely highlight specific locations, providing more accurate guidance.

  • Improved bugprone-unchecked-optional-access check, so that it does not crash during handling of optional values.

  • Improved bugprone-undefined-memory-manipulation check to support fixed-size arrays of non-trivial types.

  • Improved bugprone-unused-return-value check diagnostic message, added support for detection of unused results when cast to non-void type. Casting to void no longer suppresses issues by default, control this behavior with the new AllowCastToVoid option.

  • Improved cppcoreguidelines-avoid-non-const-global-variables check to ignore static variables declared within the scope of class/struct.

  • Improved cppcoreguidelines-avoid-reference-coroutine-parameters check to ignore false positives related to matching parameters of non coroutine functions and increase issue detection for cases involving type aliases with references.

  • Improved cppcoreguidelines-missing-std-forward check to address false positives in the capture list and body of lambdas.

  • Improved cppcoreguidelines-narrowing-conversions check by extending the IgnoreConversionFromTypes option to include types without a declaration, such as built-in types.

  • Improved cppcoreguidelines-prefer-member-initializer check to ignore delegate constructors and ignore re-assignment for reference or when initialization depend on field that is initialized before. Additionally, it now provides valid fixes for member variables initialized with macros.

  • Improved cppcoreguidelines-pro-bounds-array-to-pointer-decay check to ignore predefined expression (e.g., __func__, …).

  • Improved cppcoreguidelines-pro-bounds-constant-array-index check to perform checks on derived classes of std::array.

  • Improved cppcoreguidelines-pro-type-const-cast check to ignore casts to const or volatile type (controlled by StrictMode option) and casts in implicitly invoked code.

  • Improved cppcoreguidelines-pro-type-member-init check to ignore dependent delegate constructors.

  • Improved cppcoreguidelines-pro-type-static-cast-downcast check to disregard casts on non-polymorphic types when the StrictMode option is set to false.

  • Improved cppcoreguidelines-pro-type-vararg check to ignore false-positives in unevaluated context (e.g., decltype, sizeof, …).

  • Improved cppcoreguidelines-rvalue-reference-param-not-moved check to ignore unused parameters when they are marked as unused and parameters of deleted functions and constructors.

  • Improved google-readability-casting check to ignore constructor calls disguised as functional casts.

  • Improved google-runtime-int check to ignore false positives on user defined-literals.

  • Improved llvm-namespace-comment check to provide fixes for inline namespaces in the same format as clang-format.

  • Improved llvmlibc-callee-namespace to support customizable namespace. This matches the change made to implementation in namespace.

  • Improved llvmlibc-implementation-in-namespace to support customizable namespace. This further allows for testing the libc when the system-libc is also LLVM’s libc.

  • Improved llvmlibc-inline-function-decl to properly ignore implicit functions, such as struct constructors, and explicitly deleted functions.

  • Improved misc-const-correctness check to avoid false positive when using pointer to member function. Additionally, the check no longer emits a diagnostic when a variable that is not type-dependent is an operand of a type-dependent binary operator. Improved performance of the check through optimizations. The check no longer emits a diagnostic for non-parameter-pack variables in C++17 fold expressions.

  • Improved misc-include-cleaner check by adding option DeduplicateFindings to output one finding per symbol occurrence, avoid inserting the same header multiple times, fix a bug where IgnoreHeaders option won’t work with verbatim/std headers.

  • Improved misc-redundant-expression check to ignore false-positives in unevaluated context (e.g., decltype).

  • Improved misc-static-assert check to ignore false-positives when referring to non-constexpr variables in non-unevaluated context.

  • Improved misc-unused-using-decls check to avoid false positive when using in elaborated type and only check C++ files.

  • Improved modernize-avoid-bind check to not emit a return for fixes when the function returns void and to provide valid fixes for cases involving bound C++ operators.

  • Improved modernize-loop-convert to support for-loops with iterators initialized by free functions like begin, end, or size and avoid crash for array of dependent array and non-dereferenceable builtin types used as iterators.

  • Improved modernize-make-shared check to support std::shared_ptr implementations that inherit the reset method from a base class.

  • Improved modernize-return-braced-init-list check to ignore false-positives when constructing the container with count copies of elements with value value.

  • Improved modernize-use-auto to avoid create incorrect fix hints for pointer to array type and pointer to function type.

  • Improved modernize-use-emplace to not replace aggregates that emplace cannot construct with aggregate initialization.

  • Improved modernize-use-equals-delete check to ignore false-positives when special member function is actually used or implicit.

  • Improved modernize-use-nullptr check by adding option IgnoredTypes that can be used to exclude some pointer types.

  • Improved modernize-use-std-print check to accurately generate fixes for reordering arguments.

  • Improved modernize-use-using check to fix function pointer and forward declared typedef correctly. Added option IgnoreExternC to ignore typedef declaration in extern "C" scope.

  • Improved performance-faster-string-find check to properly escape single quotes.

  • Improved performance-for-range-copy check to handle cases where the loop variable is a structured binding.

  • Improved performance-noexcept-move-constructor to better handle conditional noexcept expressions, eliminating false-positives.

  • Improved performance-noexcept-swap check to enforce a stricter match with the swap function signature and better handling of condition noexcept expressions, eliminating false-positives. iter_swap function name is checked by default.

  • Improved readability-braces-around-statements check to ignore false-positive for if constexpr in lambda expression.

  • Improved readability-avoid-const-params-in-decls diagnostics to highlight the const location

  • Improved readability-container-contains to correctly handle integer literals with suffixes in fix-its.

  • Improved readability-container-size-empty check to detect comparison between string and empty string literals and support length() method as an alternative to size(). Resolved false positives tied to negative values from size-like methods, and one triggered by size checks below zero.

  • Improved readability-function-size check configuration to use none rather than -1 to disable some parameters.

  • Improved readability-identifier-naming check to issue accurate warnings when a type’s forward declaration precedes its definition. Additionally, it now provides appropriate warnings for struct and union in C, while also incorporating support for the Leading_upper_snake_case naming convention. The handling of typedef has been enhanced, particularly within complex types like function pointers and cases where style checks were omitted when functions started with macros. Added support for C++20 concept declarations. Camel_Snake_Case and camel_Snake_Case now detect more invalid identifier names. Fields in anonymous records (i.e. anonymous structs and unions) now can be checked with the naming rules associated with their enclosing scopes rather than the naming rules of public struct/union members.

  • Improved readability-implicit-bool-conversion check to take do-while loops into account for the AllowIntegerConditions and AllowPointerConditions options. It also now provides more consistent suggestions when parentheses are added to the return value or expressions. It also ignores false-positives for comparison containing bool bitfield.

  • Improved readability-misleading-indentation check to ignore false-positives for line started with empty macro.

  • Improved readability-non-const-parameter check to ignore false-positives in initializer list of record.

  • Improved readability-redundant-member-init check to now also detect redundant in-class initializers.

  • Improved readability-simplify-boolean-expr check by adding the new option IgnoreMacros that allows to ignore boolean expressions originating from expanded macros.

  • Improved readability-simplify-subscript-expr check by extending the default value of the Types option to include std::span.

  • Improved readability-static-accessed-through-instance check to identify calls to static member functions with out-of-class inline definitions.

Removed checks

Improvements to include-cleaner

  • Support for --only-headers flag to limit analysis to headers matching a regex

  • Recognizes references through ``concept``s

  • Builtin headers are not analyzed

  • Handling of references through friend declarations

  • Fixes around handling of IWYU pragmas on stdlib headers

  • Improved handling around references to/from template specializations

Improvements to clang-include-fixer

The improvements are…

Improvements to modularize

The improvements are…

Improvements to pp-trace

Clang-tidy Visual Studio plugin