Extra Clang Tools 15.0.0 Release Notes

Written by the LLVM Team

Introduction

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

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.

Improvements to clangd

Inlay hints

  • Provide hints for:
    • Lambda return types.

    • Forwarding functions using the underlying function call.

  • Support for standard LSP 3.17 inlay hints protocol.

  • Designator inlay hints are enabled by default.

Diagnostics

  • Improved Fix-its of some clang-tidy checks when applied with clangd.

  • Clangd now produces diagnostics for forwarding functions like make_unique.

  • Include cleaner analysis can be disabled with the Diagnostics.Includes.IgnoreHeader config option.

  • Include cleaner doesn’t diagnose exporting headers.

  • clang-tidy and include cleaner diagnostics have links to their documentation.

Semantic Highlighting

  • Semantic highlighting works for tokens that span multiple lines.

  • Mutable reference parameters in function calls receive usedAsMutableReference modifier.

Hover

  • Hover displays desugared types by default now.

Code completion

  • Improved ranking/filtering for ObjC method selectors.

  • Support for C++20 concepts and requires expressions.

Signature help

  • Signature help for function pointers.

  • Provides hints using underlying functions in forwarded calls.

Code Actions

  • New code action to generate ObjC initializers.

  • New code action to generate move/copy constructors/assignments.

  • Extract to function works for methods in addition to free functions.

  • Related diagnostics are attached to code actions response, if any.

  • Extract variable works in C and ObjC files.

  • Fix to define outline when the parameter has a braced initializer.

Miscellaneous

  • Include fixer supports symbols inside macro arguments.

  • Dependent autos are now deduced when there’s a single instantiation.

  • Support for symbols exported with using declarations in all features.

  • Fixed background-indexing priority for M1 chips.

  • Indexing for standard library symbols.

  • ObjC framework includes are spelled properly during include insertion operations.

Improvements to clang-doc

The improvements are…

Improvements to clang-query

The improvements are…

Improvements to clang-rename

The improvements are…

Improvements to clang-tidy

  • Added trace code to help narrow down any checks and the relevant source code that result in crashes.

  • Clang-tidy now consideres newlines as separators of single elements in the Checks section in .clang-tidy configuration files. Where previously a comma had to be used to distinguish elements in this list from each other, newline characters now also work as separators in the parsed YAML. That means it is advised to use YAML’s block style initiated by the pipe character | for the Checks section in order to benefit from the easier syntax that works without commas.

  • Fixed a regression introduced in clang-tidy 14.0.0, which prevented NOLINTs from suppressing diagnostics associated with macro arguments. This fixes Issue 55134.

  • Added an option -verify-config which will check the config file to ensure each Checks and CheckOptions entries are recognised.

  • .clang-tidy files can now use the more natural dictionary syntax for specifying CheckOptions.

New checks

  • New bugprone-shared-ptr-array-mismatch check.

    Finds initializations of C++ shared pointers to non-array type that are initialized with an array.

  • New bugprone-unchecked-optional-access check.

    Warns when the code is unwrapping a std::optional<T>, absl::optional<T>, or base::Optional<T> object without assuring that it contains a value.

  • New misc-confusable-identifiers check.

    Detects confusable Unicode identifiers.

  • New bugprone-assignment-in-if-condition check.

    Warns when there is an assignment within an if statement condition expression.

  • New misc-const-correctness check.

    Detects unmodified local variables and suggest adding const if the transformation is possible.

  • New modernize-macro-to-enum check.

    Replaces groups of adjacent macros with an unscoped anonymous enum.

  • New portability-std-allocator-const check.

    Report use of std::vector<const T> (and similar containers of const elements). These are not allowed in standard C++ due to undefined std::allocator<const T>. They do not compile with libstdc++ or MSVC. Future libc++ will remove the extension (D120996 <https://reviews.llvm.org/D120996>).

Changes in existing checks

  • Fixed nonsensical suggestion of altera-struct-pack-align check for empty structs.

  • Fixed a false positive in bugprone-branch-clone when the branches involve unknown expressions.

  • Fixed some false positives in bugprone-infinite-loop involving dependent expressions.

  • Fixed a crash in bugprone-sizeof-expression when sizeof(…) is compared against a __int128_t.

  • Fixed bugs in bugprone-use-after-move:

    • Treat a move in a lambda capture as happening in the function that defines the lambda, not within the body of the lambda (as we were previously doing erroneously).

    • Don’t emit an erroneous warning on self-moves.

  • Improved cert-dcl58-cpp check.

    The check now detects explicit template specializations that are handled specially.

  • Made cert-oop57-cpp more sensitive by checking for an arbitrary expression in the second argument of memset.

  • Made the fix-it of cppcoreguidelines-init-variables use false to initialize boolean variables.

  • Improved cppcoreguidelines-prefer-member-initializer check.

    Fixed an issue when there was already an initializer in the constructor and the check would try to create another initializer for the same member.

  • Fixed a false positive in cppcoreguidelines-virtual-class-destructor involving final classes. The check will not diagnose classes marked final, since those cannot be used as base classes, consequently, they can not violate the rule.

  • Fixed a crash in llvmlibc-callee-namespace when executing for C++ code that contain calls to advanced constructs, e.g. overloaded operators.

  • Fixed false positives in misc-redundant-expression:

    • Fixed a false positive involving overloaded comparison operators.

    • Fixed a false positive involving assignments in conditions. This fixes Issue 35853.

  • Fixed a false positive in misc-unused-parameters where invalid parameters were implicitly being treated as being unused. This fixes Issue 56152.

  • Fixed false positives in misc-unused-using-decls where using statements bringing operators into the scope where incorrectly marked as unused. This fixes issue 55095.

  • Fixed a false positive in modernize-deprecated-headers involving including C header files from C++ files wrapped by extern "C" { ... } blocks. Such includes will be ignored by now. By default now it doesn’t warn for including deprecated headers from header files, since that header file might be used from C source files. By passing the CheckHeaderFile=true option if header files of the project only included by C++ source files.

  • Improved performance-inefficient-vector-operation to work when the vector is a member of a structure.

  • Fixed a crash in performance-unnecessary-value-param when the specialization template has an unnecessary value parameter. Removed the fix for a template.

  • Fixed a crash in readability-const-return-type when a pure virtual function overrided has a const return type. Removed the fix for a virtual function.

  • Skipped addition of extra parentheses around member accesses (a.b) in fix-it for readability-container-data-pointer.

  • Fixed incorrect suggestions for readability-container-size-empty when smart pointers are involved.

  • Fixed a false positive in readability-non-const-parameter when the parameter is referenced by an lvalue.

  • Expanded readability-simplify-boolean-expr to simplify expressions using DeMorgan’s Theorem.

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

  • Added HashLoc information to InclusionDirective callback output.