585 lines · plain
1.. If you want to modify sections/contents permanently, you should modify both2 ReleaseNotes.rst and ReleaseNotesTemplate.txt.3 4====================================================5Extra Clang Tools |release| |ReleaseNotesTitle|6====================================================7 8.. contents::9 :local:10 :depth: 311 12Written by the `LLVM Team <https://llvm.org/>`_13 14.. only:: PreRelease15 16 .. warning::17 These are in-progress notes for the upcoming Extra Clang Tools |version| release.18 Release notes for previous releases can be found on19 `the Download Page <https://releases.llvm.org/download.html>`_.20 21Introduction22============23 24This document contains the release notes for the Extra Clang Tools, part of the25Clang release |release|. Here we describe the status of the Extra Clang Tools in26some detail, including major improvements from the previous release and new27feature work. All LLVM releases may be downloaded from the `LLVM releases web28site <https://llvm.org/releases/>`_.29 30For more information about Clang or LLVM, including information about31the latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or32the `LLVM Web Site <https://llvm.org>`_.33 34Note that if you are reading this file from a Git checkout or the35main Clang web page, this document applies to the *next* release, not36the current one. To see the release notes for a specific release, please37see the `releases page <https://llvm.org/releases/>`_.38 39What's New in Extra Clang Tools |release|?40==========================================41 42Some of the major new features and improvements to Extra Clang Tools are listed43here. Generic improvements to Extra Clang Tools as a whole or to its underlying44infrastructure are described first, followed by tool-specific sections.45 46Major New Features47------------------48 49Potentially Breaking Changes50----------------------------51 52- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been53 moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed54 in the 24th release.55 56- Removed :program:`clang-tidy`'s global options `IgnoreMacros` and57 `StrictMode`, which were documented as deprecated since58 :program:`clang-tidy-20`. Users should use the check-specific options of the59 same name instead.60 61- Renamed a few :program:`clang-tidy` check options, as they62 were misspelled:63 64 - `NamePrefixSuffixSilenceDissimilarityTreshold` to65 `NamePrefixSuffixSilenceDissimilarityThreshold` in66 :doc:`bugprone-easily-swappable-parameters67 <clang-tidy/checks/bugprone/easily-swappable-parameters>`68 69 - `CharTypdefsToIgnore` to `CharTypedefsToIgnore` in70 :doc:`bugprone-signed-char-misuse71 <clang-tidy/checks/bugprone/signed-char-misuse>`72 73- Modified the custom message format of :doc:`bugprone-unsafe-functions74 <clang-tidy/checks/bugprone/unsafe-functions>` by assigning a special meaning75 to the character ``>`` at the start of the value of the option76 ``CustomFunctions``. If the option value starts with ``>``, then the77 replacement suggestion part of the message (which would be included by78 default) is omitted. (This does not change the warning locations.)79 80- :program:`clang-tidy` now displays warnings from all non-system headers by81 default. Previously, users had to explicitly opt-in to header warnings using82 `-header-filter='.*'`. To disable warnings from non-system, set `-header-filter`83 to an empty string.84 85Improvements to clangd86----------------------87 88Inlay hints89^^^^^^^^^^^90 91Diagnostics92^^^^^^^^^^^93 94Semantic Highlighting95^^^^^^^^^^^^^^^^^^^^^96 97Compile flags98^^^^^^^^^^^^^99 100Hover101^^^^^102 103Code completion104^^^^^^^^^^^^^^^105 106Code actions107^^^^^^^^^^^^108 109- New ``Override pure virtual methods`` code action. When invoked on a class110 definition, this action automatically generates C++ ``override`` declarations111 for all pure virtual methods inherited from its base classes that have not yet112 been implemented. The generated method stubs prompts the user for the actual113 implementation. The overrides are intelligently grouped under their original114 access specifiers (e.g., ``public``, ``protected``), creating new access115 specifier blocks if necessary.116 117Signature help118^^^^^^^^^^^^^^119 120Cross-references121^^^^^^^^^^^^^^^^122 123Objective-C124^^^^^^^^^^^125 126Miscellaneous127^^^^^^^^^^^^^128 129Improvements to clang-doc130-------------------------131 132Improvements to clang-query133---------------------------134 135- Matcher queries interpreted by clang-query are now support trailing comma (,)136 in matcher arguments. Note that C++ still doesn't allow this in function137 arguments. So when porting a query to C++, remove all instances of trailing138 comma (otherwise C++ compiler will just complain about "expected expression").139 140Improvements to clang-tidy141--------------------------142 143- The :program:`check_clang_tidy.py` tool now recognizes the ``-std`` argument144 when run over C files. If ``-std`` is not specified, it defaults to145 ``c99-or-later``.146 147- :program:`clang-tidy` now displays warnings from all non-system headers by148 default. Previously, users had to explicitly opt-in to header warnings using149 `-header-filter='.*'`. To disable warnings from non-system, set `-header-filter`150 to an empty string.151 152- :program:`clang-tidy` no longer attempts to analyze code from system headers153 by default, greatly improving performance. This behavior is disabled if the154 `SystemHeaders` option is enabled.155 156- :program:`clang-tidy` now supports query based custom checks by `CustomChecks`157 configuration option.158 :doc:`Query Based Custom Check Document <clang-tidy/QueryBasedCustomChecks>`159 160- The :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` scripts161 now run checks in parallel by default using all available hardware threads.162 Both scripts display the number of threads being used in their output.163 164- Improved :program:`run-clang-tidy.py` by adding a new option165 `enable-check-profile` to enable per-check timing profiles and print a166 report based on all analyzed files.167 168- Improved documentation of the `-line-filter` command-line flag of169 :program:`clang-tidy` and :program:`run-clang-tidy.py`.170 171- Improved :program:`clang-tidy` option `-quiet` by suppressing diagnostic172 count messages.173 174- Improved :program:`clang-tidy` by not crashing when an empty `directory`175 field is used in a compilation database; the current working directory176 will be used instead, and an error message will be printed.177 178- Removed :program:`clang-tidy`'s global options `IgnoreMacros` and179 `StrictMode`, which were documented as deprecated since180 :program:`clang-tidy-20`. Users should use the check-specific options of the181 same name instead.182 183- Improved :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py`184 scripts by adding the `-hide-progress` option to suppress progress and185 informational messages.186 187- Deprecated the :program:`clang-tidy` ``zircon`` module. All checks have been188 moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed189 in the 24th release.190 191New checks192^^^^^^^^^^193 194- New :doc:`bugprone-derived-method-shadowing-base-method195 <clang-tidy/checks/bugprone/derived-method-shadowing-base-method>` check.196 197 Finds derived class methods that shadow a (non-virtual) base class method.198 199- New :doc:`bugprone-invalid-enum-default-initialization200 <clang-tidy/checks/bugprone/invalid-enum-default-initialization>` check.201 202 Detects default initialization (to 0) of variables with ``enum`` type where203 the enum has no enumerator with value of 0.204 205- New :doc:`cppcoreguidelines-pro-bounds-avoid-unchecked-container-access206 <clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access>`207 check.208 209 Finds calls to ``operator[]`` in STL containers and suggests replacing them210 with safe alternatives.211 212- New :doc:`google-runtime-float213 <clang-tidy/checks/google/runtime-float>` check.214 215 Finds uses of ``long double`` and suggests against their use due to lack of216 portability.217 218- New :doc:`llvm-mlir-op-builder219 <clang-tidy/checks/llvm/use-new-mlir-op-builder>` check.220 221 Checks for uses of MLIR's old/to be deprecated ``OpBuilder::create<T>`` form222 and suggests using ``T::create`` instead.223 224- New :doc:`llvm-use-ranges225 <clang-tidy/checks/llvm/use-ranges>` check.226 227 Finds calls to STL library iterator algorithms that could be replaced with228 LLVM range-based algorithms from ``llvm/ADT/STLExtras.h``.229 230- New :doc:`misc-override-with-different-visibility231 <clang-tidy/checks/misc/override-with-different-visibility>` check.232 233 Finds virtual function overrides with different visibility than the function234 in the base class.235 236- New :doc:`readability-redundant-parentheses237 <clang-tidy/checks/readability/redundant-parentheses>` check.238 239 Detect redundant parentheses.240 241- New :doc:`readability-redundant-typename242 <clang-tidy/checks/readability/redundant-typename>` check.243 244 Finds redundant uses of the ``typename`` keyword.245 246New check aliases247^^^^^^^^^^^^^^^^^248 249- Renamed :doc:`cert-dcl50-cpp <clang-tidy/checks/cert/dcl50-cpp>` to250 :doc:`modernize-avoid-variadic-functions251 <clang-tidy/checks/modernize/avoid-variadic-functions>`252 keeping initial check as an alias to the new one.253 254- Renamed :doc:`cert-dcl58-cpp <clang-tidy/checks/cert/dcl58-cpp>` to255 :doc:`bugprone-std-namespace-modification256 <clang-tidy/checks/bugprone/std-namespace-modification>`257 keeping initial check as an alias to the new one.258 259- Renamed :doc:`cert-env33-c <clang-tidy/checks/cert/env33-c>` to260 :doc:`bugprone-command-processor261 <clang-tidy/checks/bugprone/command-processor>`262 keeping initial check as an alias to the new one.263 264- Renamed :doc:`cert-err34-c <clang-tidy/checks/cert/err34-c>` to265 :doc:`bugprone-unchecked-string-to-number-conversion266 <clang-tidy/checks/bugprone/unchecked-string-to-number-conversion>`267 keeping initial check as an alias to the new one.268 269- Renamed :doc:`cert-err52-cpp <clang-tidy/checks/cert/err52-cpp>` to270 :doc:`modernize-avoid-setjmp-longjmp271 <clang-tidy/checks/modernize/avoid-setjmp-longjmp>`272 keeping initial check as an alias to the new one.273 274- Renamed :doc:`cert-err58-cpp <clang-tidy/checks/cert/err58-cpp>` to275 :doc:`bugprone-throwing-static-initialization276 <clang-tidy/checks/bugprone/throwing-static-initialization>`277 keeping initial check as an alias to the new one.278 279- Renamed :doc:`cert-err60-cpp <clang-tidy/checks/cert/err60-cpp>` to280 :doc:`bugprone-exception-copy-constructor-throws281 <clang-tidy/checks/bugprone/exception-copy-constructor-throws>`282 283- Renamed :doc:`cert-flp30-c <clang-tidy/checks/cert/flp30-c>` to284 :doc:`bugprone-float-loop-counter285 <clang-tidy/checks/bugprone/float-loop-counter>`286 keeping initial check as an alias to the new one.287 288- Renamed :doc:`cert-mem57-cpp <clang-tidy/checks/cert/mem57-cpp>` to289 :doc:`bugprone-default-operator-new-on-overaligned-type290 <clang-tidy/checks/bugprone/default-operator-new-on-overaligned-type>`291 keeping initial check as an alias to the new one.292 293- Renamed :doc:`cert-msc30-c <clang-tidy/checks/cert/msc30-c>` to294 :doc:`misc-predictable-rand295 <clang-tidy/checks/misc/predictable-rand>`296 keeping initial check as an alias to the new one.297 298- Renamed :doc:`cert-msc32-c <clang-tidy/checks/cert/msc32-c>` to299 :doc:`bugprone-random-generator-seed300 <clang-tidy/checks/bugprone/random-generator-seed>`301 keeping initial check as an alias to the new one.302 303- Renamed :doc:`cert-msc50-cpp <clang-tidy/checks/cert/msc50-cpp>` to304 :doc:`misc-predictable-rand305 <clang-tidy/checks/misc/predictable-rand>`306 keeping initial check as an alias to the new one.307 308- Renamed :doc:`cert-msc51-cpp <clang-tidy/checks/cert/msc51-cpp>` to309 :doc:`bugprone-random-generator-seed310 <clang-tidy/checks/bugprone/random-generator-seed>`311 keeping initial check as an alias to the new one.312 313- Renamed :doc:`cert-oop57-cpp <clang-tidy/checks/cert/oop57-cpp>` to314 :doc:`bugprone-raw-memory-call-on-non-trivial-type315 <clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type>`316 keeping initial check as an alias to the new one.317 318- Renamed :doc:`cert-oop58-cpp <clang-tidy/checks/cert/oop58-cpp>` to319 :doc:`bugprone-copy-constructor-mutates-argument320 <clang-tidy/checks/bugprone/copy-constructor-mutates-argument>`321 keeping initial check as an alias to the new one.322 323Changes in existing checks324^^^^^^^^^^^^^^^^^^^^^^^^^^325 326- Improved :doc:`bugprone-easily-swappable-parameters327 <clang-tidy/checks/bugprone/easily-swappable-parameters>` check by328 correcting a spelling mistake on its option329 ``NamePrefixSuffixSilenceDissimilarityTreshold``.330 331- Improved :doc:`bugprone-exception-escape332 <clang-tidy/checks/bugprone/exception-escape>` check's handling of lambdas:333 exceptions from captures are now diagnosed, exceptions in the bodies of334 lambdas that aren't actually invoked are not. Additionally, fixed an issue335 where the check wouldn't diagnose throws in arguments to functions or336 constructors. Added fine-grained configuration via options337 `CheckDestructors`, `CheckMoveMemberFunctions`, `CheckMain`,338 `CheckedSwapFunctions`, and `CheckNothrowFunctions`.339 340- Improved :doc:`bugprone-infinite-loop341 <clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for342 variables introduced by structured bindings.343 344- Improved :doc:`bugprone-invalid-enum-default-initialization345 <clang-tidy/checks/bugprone/invalid-enum-default-initialization>` with new346 `IgnoredEnums` option to ignore specified enums during analysis.347 348- Improved :doc:`bugprone-narrowing-conversions349 <clang-tidy/checks/bugprone/narrowing-conversions>` check by fixing350 false positive from analysis of a conditional expression in C.351 352- Improved :doc:`bugprone-not-null-terminated-result353 <clang-tidy/checks/bugprone/not-null-terminated-result>` check by fixing354 bogus fix-its for ``strncmp`` and ``wcsncmp`` on Windows and355 a crash caused by certain value-dependent expressions.356 357- Improved :doc:`bugprone-reserved-identifier358 <clang-tidy/checks/bugprone/reserved-identifier>` check by ignoring359 declarations and macros in system headers.360 361- Improved :doc:`bugprone-signed-char-misuse362 <clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing363 false positives on C23 enums with the fixed underlying type of signed char.364 365- Improved :doc:`bugprone-sizeof-expression366 <clang-tidy/checks/bugprone/sizeof-expression>` check by fixing367 a crash on ``sizeof`` of an array of dependent type.368 369- Improved :doc:`bugprone-suspicious-include370 <clang-tidy/checks/bugprone/suspicious-include>` check by adding371 `IgnoredRegex` option.372 373- Improved :doc:`bugprone-tagged-union-member-count374 <clang-tidy/checks/bugprone/tagged-union-member-count>` by fixing a false375 positive when enums or unions from system header files or the ``std``376 namespace are treated as the tag or the data part of a user-defined377 tagged union respectively.378 379- Improved :doc:`bugprone-throw-keyword-missing380 <clang-tidy/checks/bugprone/throw-keyword-missing>` check by only considering381 the canonical types of base classes as written and adding a note on the base382 class that triggered the warning.383 384- Improved :doc:`bugprone-unchecked-optional-access385 <clang-tidy/checks/bugprone/unchecked-optional-access>` check by supporting386 ``NullableValue::makeValue`` and ``NullableValue::makeValueInplace`` to387 prevent false-positives for ``BloombergLP::bdlb::NullableValue`` type, and by388 adding the `IgnoreValueCalls` option to suppress diagnostics for389 ``optional::value()`` and the `IgnoreSmartPointerDereference` option to390 ignore optionals reached via smart-pointer-like dereference, while still391 diagnosing UB-prone dereferences via ``operator*`` and ``operator->``.392 393- Improved :doc:`bugprone-unhandled-self-assignment394 <clang-tidy/checks/bugprone/unhandled-self-assignment>` check by adding395 an additional matcher that generalizes the copy-and-swap idiom pattern396 detection.397 398- Improved :doc:`bugprone-unsafe-functions399 <clang-tidy/checks/bugprone/unsafe-functions>` check by hiding the default400 suffix when the reason starts with the character `>` in the `CustomFunctions`401 option.402 403- Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables404 <clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables>` check405 by adding a new option `AllowThreadLocal` that suppresses warnings on406 non-const global variables with thread-local storage duration.407 408- Improved :doc:`cppcoreguidelines-init-variables409 <clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the410 insertion location for function pointers with multiple parameters.411 412- Improved :doc:`cppcoreguidelines-macro-usage413 <clang-tidy/checks/cppcoreguidelines/macro-usage>` check by excluding macro414 bodies that starts with ``__attribute__((..))`` keyword.415 Such a macro body is unlikely a proper expression and so suggesting users416 an impossible rewrite into a template function should be avoided.417 418- Improved :doc:`cppcoreguidelines-prefer-member-initializer419 <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to420 avoid false positives on inherited members in class templates.421 422- Improved :doc:`cppcoreguidelines-pro-bounds-pointer-arithmetic423 <clang-tidy/checks/cppcoreguidelines/pro-bounds-pointer-arithmetic>` check424 adding an option to allow pointer arithmetic via prefix/postfix increment or425 decrement operators.426 427- Improved :doc:`google-readability-casting428 <clang-tidy/checks/google/readability-casting>` check by adding fix-it429 notes for downcasts and casts to void pointer.430 431- Improved :doc:`google-readability-todo432 <clang-tidy/checks/google/readability-todo>` check to accept the new TODO433 format from the Google Style Guide.434 435- Improved :doc:`llvm-prefer-isa-or-dyn-cast-in-conditionals436 <clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals>` check:437 438 - Fix-it handles callees with nested-name-specifier correctly.439 440 - ``if`` statements with init-statement (``if (auto X = ...; ...)``) are441 handled correctly.442 443 - ``for`` loops are supported.444 445- Improved :doc:`misc-const-correctness446 <clang-tidy/checks/misc/const-correctness>` check to avoid false447 positives when pointers is transferred to non-const references448 and avoid false positives of function pointer and fix false449 positives on return of non-const pointer and fix false positives on450 pointer-to-member operator.451 452- Improved :doc:`misc-coroutine-hostile-raii453 <clang-tidy/checks/misc/coroutine-hostile-raii>` check by adding the option454 `AllowedCallees`, that allows exempting safely awaitable callees from the455 check.456 457- Improved :doc:`misc-header-include-cycle458 <clang-tidy/checks/misc/header-include-cycle>` check performance.459 460- Improved :doc:`modernize-avoid-c-arrays461 <clang-tidy/checks/modernize/avoid-c-arrays>` to not diagnose array types462 which are part of an implicit instantiation of a template.463 464- Improved :doc:`modernize-use-constraints465 <clang-tidy/checks/modernize/use-constraints>` check by fixing a crash on466 uses of non-standard ``enable_if`` with a signature different from467 ``std::enable_if`` (such as ``boost::enable_if``).468 469- Improved :doc:`modernize-use-default-member-init470 <clang-tidy/checks/modernize/use-default-member-init>` check to471 enhance the robustness of the member initializer detection.472 473- Improved :doc:`modernize-use-designated-initializers474 <clang-tidy/checks/modernize/use-designated-initializers>` check to475 suggest using designated initializers for aliased aggregate types.476 477- Improved :doc:`modernize-use-integer-sign-comparison478 <clang-tidy/checks/modernize/use-integer-sign-comparison>` by providing479 correct fix-its when the right-hand side of a comparison contains a480 non-C-style cast.481 482- Improved :doc:`modernize-use-nullptr483 <clang-tidy/checks/modernize/use-nullptr>` check by fixing a crash484 on Windows when the check was enabled with a 32-bit :program:`clang-tidy`485 binary.486 487- Improved :doc:`modernize-use-scoped-lock488 <clang-tidy/checks/modernize/use-scoped-lock>` check by fixing a crash489 on malformed code (common when using :program:`clang-tidy` through490 :program:`clangd`).491 492- Improved :doc:`modernize-use-std-format493 <clang-tidy/checks/modernize/use-std-format>` check to correctly match494 when the format string is converted to a different type by an implicit495 constructor call.496 497- Improved :doc:`modernize-use-std-print498 <clang-tidy/checks/modernize/use-std-print>` check to correctly match499 when the format string is converted to a different type by an implicit500 constructor call, and fixed a crash when handling format strings501 containing non-ASCII characters.502 503- Improved :doc:`performance-unnecessary-copy-initialization504 <clang-tidy/checks/performance/unnecessary-copy-initialization>` by printing505 the type of the diagnosed variable.506 507- Improved :doc:`performance-unnecessary-value-param508 <clang-tidy/checks/performance/unnecessary-value-param>` by printing509 the type of the diagnosed variable and correctly generating fix-it hints for510 parameter-pack arguments.511 512- Improved :doc:`portability-template-virtual-member-function513 <clang-tidy/checks/portability/template-virtual-member-function>` check to514 avoid false positives on pure virtual member functions.515 516- Improved :doc:`readability-container-contains517 <clang-tidy/checks/readability/container-contains>` to support string518 comparisons to ``npos``. Internal changes may cause new rare false positives519 in non-standard containers.520 521- Improved :doc:`readability-container-data-pointer522 <clang-tidy/checks/readability/container-data-pointer>` check by correctly523 adding parentheses when the container expression is a dereference.524 525- Improved :doc:`readability-container-size-empty526 <clang-tidy/checks/readability/container-size-empty>` check by correctly527 generating fix-it hints when size method is called from implicit ``this``,528 ignoring default constructors with user provided arguments and adding529 detection in container's method except ``empty``.530 531- Improved :doc:`readability-duplicate-include532 <clang-tidy/checks/readability/duplicate-include>` check by adding533 the ``IgnoredFilesList`` option (semicolon-separated list of regexes or534 filenames) to allow intentional duplicates.535 536- Improved :doc:`readability-identifier-naming537 <clang-tidy/checks/readability/identifier-naming>` check by ignoring538 declarations and macros in system headers. The documentation is also improved539 to differentiate the general options from the specific ones. Options for540 fine-grained control over ``constexpr`` variables were added.541 542- Improved :doc:`readability-implicit-bool-conversion543 <clang-tidy/checks/readability/implicit-bool-conversion>` check by correctly544 adding parentheses when the inner expression are implicitly converted545 multiple times.546 547- Improved :doc:`readability-qualified-auto548 <clang-tidy/checks/readability/qualified-auto>` check by adding the option549 `IgnoreAliasing`, that allows not looking at underlying types of type aliases.550 551- Improved :doc:`readability-uppercase-literal-suffix552 <clang-tidy/checks/readability/uppercase-literal-suffix>` check to recognize553 literal suffixes added in C++23 and C23.554 555- Improved :doc:`readability-use-concise-preprocessor-directives556 <clang-tidy/checks/readability/use-concise-preprocessor-directives>` check to557 generate correct fix-its for forms without a space after the directive.558 559Removed checks560^^^^^^^^^^^^^^561 562Miscellaneous563^^^^^^^^^^^^^564 565Improvements to include-fixer566-----------------------------567 568The improvements are...569 570Improvements to clang-include-fixer571-----------------------------------572 573The improvements are...574 575Improvements to modularize576--------------------------577 578The improvements are...579 580Improvements to pp-trace581------------------------582 583Clang-tidy Visual Studio plugin584-------------------------------585