[clang-tools-extra] [clang-tidy] Support LineFilter in .clang-tidy configuration files (PR #202575)
Peiqi Li via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 7 06:34:50 PDT 2026
https://github.com/voyager-jhk updated https://github.com/llvm/llvm-project/pull/202575
>From 0b6b0aa7ffb05b421188e4bc582f4d92c803fa4a Mon Sep 17 00:00:00 2001
From: voyager-jhk <voyager.lpq at gmail.com>
Date: Tue, 9 Jun 2026 18:32:50 +0800
Subject: [PATCH] [clang-tidy] Support LineFilter in .clang-tidy configuration
files
Previously, the `LineFilter` option was strictly read from the global command-line
arguments. This made it completely inaccessible to Language Servers like `clangd`,
which rely exclusively on `.clang-tidy` configuration files.
This patch adds `LineFilter` to the `ClangTidyOptions` struct, implements YAML
serialization, and defines merge semantics. The `DiagnosticConsumer` is updated
to fallback to the local configuration only if the global command-line filter is empty,
preserving the expected CLI-override behavior.
Fixes #59263
---
.../ClangTidyDiagnosticConsumer.cpp | 19 +-
.../clang-tidy/ClangTidyOptions.cpp | 19 +
.../clang-tidy/ClangTidyOptions.h | 10 +
clang-tools-extra/clangd/ParsedAST.cpp | 107 ++-
.../clangd/unittests/DiagnosticsTests.cpp | 19 +
clang-tools-extra/docs/ReleaseNotes.rst | 862 ++++++++++++++++++
.../infrastructure/line-filter-config.cpp | 18 +
.../clang-tidy/ClangTidyOptionsTest.cpp | 15 +
8 files changed, 1013 insertions(+), 56 deletions(-)
create mode 100644 clang-tools-extra/docs/ReleaseNotes.rst
create mode 100644 clang-tools-extra/test/clang-tidy/infrastructure/line-filter-config.cpp
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 48d8c76bd4db6..4f8bc0fdd7726 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -482,19 +482,12 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,
unsigned LineNumber) const {
- if (Context.getGlobalOptions().LineFilter.empty())
- return true;
- for (const FileFilter &Filter : Context.getGlobalOptions().LineFilter) {
- if (FileName.ends_with(Filter.Name)) {
- if (Filter.LineRanges.empty())
- return true;
- return llvm::any_of(
- Filter.LineRanges, [&](const FileFilter::LineRange &Range) {
- return Range.first <= LineNumber && LineNumber <= Range.second;
- });
- }
- }
- return false;
+ const std::vector<FileFilter> *Filters =
+ &Context.getGlobalOptions().LineFilter;
+ if (Filters->empty() && Context.getOptions().LineFilter)
+ Filters = &*Context.getOptions().LineFilter;
+
+ return tidy::passesLineFilter(*Filters, FileName, LineNumber);
}
void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 2ef23ede09972..e8962641f8757 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -11,6 +11,7 @@
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
@@ -243,6 +244,7 @@ template <> struct MappingTraits<ClangTidyOptions> {
IO.mapOptional("UseColor", Options.UseColor);
IO.mapOptional("SystemHeaders", Options.SystemHeaders);
IO.mapOptional("CustomChecks", Options.CustomChecks);
+ IO.mapOptional("LineFilter", Options.LineFilter);
}
};
@@ -303,6 +305,7 @@ ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
overrideValue(FormatStyle, Other.FormatStyle);
overrideValue(User, Other.User);
overrideValue(UseColor, Other.UseColor);
+ overrideValue(LineFilter, Other.LineFilter);
mergeVectors(ExtraArgs, Other.ExtraArgs);
mergeVectors(ExtraArgsBefore, Other.ExtraArgsBefore);
mergeVectors(RemovedArgs, Other.RemovedArgs);
@@ -526,6 +529,22 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef Directory) {
return std::nullopt;
}
+bool passesLineFilter(ArrayRef<FileFilter> LineFilter, StringRef FileName,
+ unsigned LineNumber) {
+ if (LineFilter.empty())
+ return true;
+ for (const FileFilter &Filter : LineFilter) {
+ if (!FileName.ends_with(Filter.Name))
+ continue;
+ if (Filter.LineRanges.empty())
+ return true;
+ return llvm::any_of(Filter.LineRanges, [LineNumber](const auto &Range) {
+ return Range.first <= LineNumber && LineNumber <= Range.second;
+ });
+ }
+ return false;
+}
+
/// Parses -line-filter option and stores it to the \c Options.
std::error_code parseLineFilter(StringRef LineFilter,
clang::tidy::ClangTidyGlobalOptions &Options) {
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index 73fdbabd5bdba..2873e03e9abbd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -10,6 +10,7 @@
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
#include "clang/Basic/DiagnosticIDs.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
@@ -70,6 +71,9 @@ struct ClangTidyOptions {
/// Checks filter.
std::optional<std::string> Checks;
+ /// Line filter.
+ std::optional<std::vector<FileFilter>> LineFilter;
+
/// WarningsAsErrors filter.
std::optional<std::string> WarningsAsErrors;
@@ -338,6 +342,12 @@ class FileOptionsProvider : public FileOptionsBaseProvider {
std::vector<OptionsSource> getRawOptions(StringRef FileName) override;
};
+/// Returns true if a diagnostic at \p LineNumber in \p FileName should be
+/// displayed according to \p LineFilter. An empty filter allows all
+/// diagnostics.
+bool passesLineFilter(ArrayRef<FileFilter> LineFilter, StringRef FileName,
+ unsigned LineNumber);
+
/// Parses LineFilter from JSON and stores it to the \p Options.
std::error_code parseLineFilter(StringRef LineFilter,
ClangTidyGlobalOptions &Options);
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index df56420cd7f24..1a1bc05b0632e 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -383,6 +383,23 @@ void applyWarningOptions(llvm::ArrayRef<std::string> ExtraArgs,
}
}
+bool passesTidyLineFilter(const tidy::ClangTidyOptions &Options,
+ SourceLocation Loc, const SourceManager &SM) {
+ if (!Options.LineFilter)
+ return true;
+
+ if (!Loc.isValid())
+ return true;
+
+ FileID FID = SM.getDecomposedExpansionLoc(Loc).first;
+ OptionalFileEntryRef File = SM.getFileEntryRefForID(FID);
+ if (!File)
+ return true;
+
+ return tidy::passesLineFilter(*Options.LineFilter, File->getName(),
+ SM.getExpansionLineNumber(Loc));
+}
+
std::vector<Diag> getIncludeCleanerDiags(ParsedAST &AST, llvm::StringRef Code,
const ThreadsafeFS &TFS) {
auto &Cfg = Config::current();
@@ -605,50 +622,54 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
SourceLocation());
}
- ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel,
- const clang::Diagnostic &Info) {
- auto It = OverriddenSeverity.find(Info.getID());
- if (It != OverriddenSeverity.end())
- DiagLevel = It->second;
-
- if (!CTChecks.empty()) {
- std::string CheckName = CTContext->getCheckName(Info.getID());
- bool IsClangTidyDiag = !CheckName.empty();
- if (IsClangTidyDiag) {
- if (Cfg.Diagnostics.Suppress.contains(CheckName))
- return DiagnosticsEngine::Ignored;
- // Check for suppression comment. Skip the check for diagnostics not
- // in the main file, because we don't want that function to query the
- // source buffer for preamble files. For the same reason, we ask
- // shouldSuppressDiagnostic to avoid I/O.
- // We let suppression comments take precedence over warning-as-error
- // to match clang-tidy's behaviour.
- bool IsInsideMainFile =
- Info.hasSourceManager() &&
- isInsideMainFile(Info.getLocation(), Info.getSourceManager());
- SmallVector<tooling::Diagnostic, 1> TidySuppressedErrors;
- if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
- DiagLevel, Info, TidySuppressedErrors,
- /*AllowIO=*/false,
- /*EnableNolintBlocks=*/true)) {
- // FIXME: should we expose the suppression error (invalid use of
- // NOLINT comments)?
- return DiagnosticsEngine::Ignored;
- }
- if (!CTContext->getOptions().SystemHeaders.value_or(false) &&
- Info.hasSourceManager() &&
- Info.getSourceManager().isInSystemMacro(Info.getLocation()))
- return DiagnosticsEngine::Ignored;
-
- // Check for warning-as-error.
- if (DiagLevel == DiagnosticsEngine::Warning &&
- CTContext->treatAsError(CheckName)) {
- return DiagnosticsEngine::Error;
+ ASTDiags.setLevelAdjuster(
+ [&](DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) {
+ auto It = OverriddenSeverity.find(Info.getID());
+ if (It != OverriddenSeverity.end())
+ DiagLevel = It->second;
+
+ if (!CTChecks.empty()) {
+ std::string CheckName = CTContext->getCheckName(Info.getID());
+ bool IsClangTidyDiag = !CheckName.empty();
+ if (IsClangTidyDiag) {
+ if (Cfg.Diagnostics.Suppress.contains(CheckName))
+ return DiagnosticsEngine::Ignored;
+ if (Info.hasSourceManager() &&
+ !passesTidyLineFilter(ClangTidyOpts, Info.getLocation(),
+ Info.getSourceManager()))
+ return DiagnosticsEngine::Ignored;
+ // Check for suppression comment. Skip the check for diagnostics
+ // not in the main file, because we don't want that function to
+ // query the source buffer for preamble files. For the same
+ // reason, we ask shouldSuppressDiagnostic to avoid I/O. We let
+ // suppression comments take precedence over warning-as-error to
+ // match clang-tidy's behaviour.
+ bool IsInsideMainFile =
+ Info.hasSourceManager() &&
+ isInsideMainFile(Info.getLocation(), Info.getSourceManager());
+ SmallVector<tooling::Diagnostic, 1> TidySuppressedErrors;
+ if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
+ DiagLevel, Info, TidySuppressedErrors,
+ /*AllowIO=*/false,
+ /*EnableNolintBlocks=*/true)) {
+ // FIXME: should we expose the suppression error (invalid use of
+ // NOLINT comments)?
+ return DiagnosticsEngine::Ignored;
+ }
+ if (!CTContext->getOptions().SystemHeaders.value_or(false) &&
+ Info.hasSourceManager() &&
+ Info.getSourceManager().isInSystemMacro(Info.getLocation()))
+ return DiagnosticsEngine::Ignored;
+
+ // Check for warning-as-error.
+ if (DiagLevel == DiagnosticsEngine::Warning &&
+ CTContext->treatAsError(CheckName)) {
+ return DiagnosticsEngine::Error;
+ }
+ }
}
- }
- }
- return DiagLevel;
- });
+ return DiagLevel;
+ });
// Add IncludeFixer which can recover diagnostics caused by missing includes
// (e.g. incomplete type) and attach include insertion fixes to diagnostics.
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 6d91ac1ef1e8e..b8703a8384bcc 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -2078,6 +2078,25 @@ TEST(Diagnostics, TidyDiagsArentAffectedFromWerror) {
diagSeverity(DiagnosticsEngine::Error)))));
}
+TEST(Diagnostics, TidyLineFilter) {
+ Annotations Test(R"cpp(
+ $skip[[typedef int Skip]];
+ $keep[[typedef int Keep]];
+ $after[[typedef int After]];
+ )cpp");
+ TestTU TU = TestTU::withCode(Test.code());
+ unsigned KeepLine = Test.range("keep").start.line + 1;
+ TU.ClangTidyProvider = [KeepLine](tidy::ClangTidyOptions &Opts,
+ llvm::StringRef) {
+ Opts.Checks = "modernize-use-using";
+ Opts.LineFilter =
+ std::vector<tidy::FileFilter>{{"TestTU.cpp", {{KeepLine, KeepLine}}}};
+ };
+ EXPECT_THAT(TU.build().getDiagnostics(),
+ ifTidyChecks(ElementsAre(Diag(
+ Test.range("keep"), "use 'using' instead of 'typedef'"))));
+}
+
TEST(Diagnostics, DeprecatedDiagsAreHints) {
ClangdDiagnosticOptions Opts;
std::optional<clangd::Diagnostic> Diag;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
new file mode 100644
index 0000000000000..e1883ae3b1fcc
--- /dev/null
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -0,0 +1,862 @@
+.. If you want to modify sections/contents permanently, you should modify both
+ ReleaseNotes.rst and ReleaseNotesTemplate.txt.
+
+====================================================
+Extra Clang Tools |release| |ReleaseNotesTitle|
+====================================================
+
+.. contents::
+ :local:
+ :depth: 3
+
+Written by the `LLVM Team <https://llvm.org/>`_
+
+.. only:: PreRelease
+
+ .. warning::
+ These are in-progress notes for the upcoming Extra Clang Tools |version| release.
+ Release notes for previous releases can be found on
+ `the Download Page <https://releases.llvm.org/download.html>`_.
+
+Introduction
+============
+
+This document contains the release notes for the Extra Clang Tools, part of the
+Clang release |release|. 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 <https://llvm.org/releases/>`_.
+
+For more information about Clang or LLVM, including information about
+the latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or
+the `LLVM Web Site <https://llvm.org>`_.
+
+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 <https://llvm.org/releases/>`_.
+
+What's New in Extra Clang Tools |release|?
+==========================================
+
+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 :doc:`modernize-use-using <clang-tidy/checks/modernize/use-using>` check
+ now sets the `IgnoreExternC` option to `true` by default. The check will
+ no longer transform ``typedef``\ s within ``extern "C"`` blocks.
+
+- Deprecated the :program:`clang-tidy` check :doc:`performance-faster-string-find
+ <clang-tidy/checks/performance/faster-string-find>`. It has been renamed to
+ :doc:`performance-prefer-single-char-overloads
+ <clang-tidy/checks/performance/prefer-single-char-overloads>`.
+ The original check will be removed in the 25th release.
+
+- Removed the :program:`clang-tidy` ``hicpp`` module. All checks have been moved
+ to the other modules. Use the replacement checks instead:
+
+ ================================== ========================================================================
+ Removed check Replacement check
+ ================================== ========================================================================
+ ``hicpp-avoid-c-arrays`` :doc:`modernize-avoid-c-arrays
+ <clang-tidy/checks/modernize/avoid-c-arrays>`
+ ``hicpp-avoid-goto`` :doc:`cppcoreguidelines-avoid-goto
+ <clang-tidy/checks/cppcoreguidelines/avoid-goto>`
+ ``hicpp-braces-around-statements`` :doc:`readability-braces-around-statements
+ <clang-tidy/checks/readability/braces-around-statements>`
+ ``hicpp-deprecated-headers`` :doc:`modernize-deprecated-headers
+ <clang-tidy/checks/modernize/deprecated-headers>`
+ ``hicpp-exception-baseclass`` :doc:`bugprone-std-exception-baseclass
+ <clang-tidy/checks/bugprone/std-exception-baseclass>`
+ ``hicpp-explicit-conversions`` :doc:`misc-explicit-constructor
+ <clang-tidy/checks/misc/explicit-constructor>`
+ ``hicpp-function-size`` :doc:`readability-function-size
+ <clang-tidy/checks/readability/function-size>`
+ ``hicpp-ignored-remove-result`` :doc:`bugprone-unused-return-value
+ <clang-tidy/checks/bugprone/unused-return-value>`
+ ``hicpp-invalid-access-moved`` :doc:`bugprone-use-after-move
+ <clang-tidy/checks/bugprone/use-after-move>`
+ ``hicpp-member-init`` :doc:`cppcoreguidelines-pro-type-member-init
+ <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>`
+ ``hicpp-move-const-arg`` :doc:`performance-move-const-arg
+ <clang-tidy/checks/performance/move-const-arg>`
+ ``hicpp-multiway-paths-covered`` :doc:`bugprone-unhandled-code-paths
+ <clang-tidy/checks/bugprone/unhandled-code-paths>`
+ ``hicpp-named-parameter`` :doc:`readability-named-parameter
+ <clang-tidy/checks/readability/named-parameter>`
+ ``hicpp-new-delete-operators`` :doc:`misc-new-delete-overloads
+ <clang-tidy/checks/misc/new-delete-overloads>`
+ ``hicpp-no-array-decay`` :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay
+ <clang-tidy/checks/cppcoreguidelines/pro-bounds-array-to-pointer-decay>`
+ ``hicpp-no-assembler`` :doc:`portability-no-assembler
+ <clang-tidy/checks/portability/no-assembler>`
+ ``hicpp-no-malloc`` :doc:`cppcoreguidelines-no-malloc
+ <clang-tidy/checks/cppcoreguidelines/no-malloc>`
+ ``hicpp-noexcept-move`` :doc:`performance-noexcept-move-constructor
+ <clang-tidy/checks/performance/noexcept-move-constructor>`
+ ``hicpp-signed-bitwise`` :doc:`bugprone-signed-bitwise
+ <clang-tidy/checks/bugprone/signed-bitwise>`
+ ``hicpp-special-member-functions`` :doc:`cppcoreguidelines-special-member-functions
+ <clang-tidy/checks/cppcoreguidelines/special-member-functions>`
+ ``hicpp-static-assert`` :doc:`misc-static-assert
+ <clang-tidy/checks/misc/static-assert>`
+ ``hicpp-uppercase-literal-suffix`` :doc:`readability-uppercase-literal-suffix
+ <clang-tidy/checks/readability/uppercase-literal-suffix>`
+ ``hicpp-undelegated-constructor`` :doc:`bugprone-undelegated-constructor
+ <clang-tidy/checks/bugprone/undelegated-constructor>`
+ ``hicpp-use-auto`` :doc:`modernize-use-auto
+ <clang-tidy/checks/modernize/use-auto>`
+ ``hicpp-use-emplace`` :doc:`modernize-use-emplace
+ <clang-tidy/checks/modernize/use-emplace>`
+ ``hicpp-use-equals-default`` :doc:`modernize-use-equals-default
+ <clang-tidy/checks/modernize/use-equals-default>`
+ ``hicpp-use-equals-delete`` :doc:`modernize-use-equals-delete
+ <clang-tidy/checks/modernize/use-equals-delete>`
+ ``hicpp-use-noexcept`` :doc:`modernize-use-noexcept
+ <clang-tidy/checks/modernize/use-noexcept>`
+ ``hicpp-use-nullptr`` :doc:`modernize-use-nullptr
+ <clang-tidy/checks/modernize/use-nullptr>`
+ ``hicpp-use-override`` :doc:`modernize-use-override
+ <clang-tidy/checks/modernize/use-override>`
+ ``hicpp-vararg`` :doc:`cppcoreguidelines-pro-type-vararg
+ <clang-tidy/checks/cppcoreguidelines/pro-type-vararg>`
+ ================================== ========================================================================
+
+Improvements to clangd
+----------------------
+
+Inlay hints
+^^^^^^^^^^^
+
+Diagnostics
+^^^^^^^^^^^
+
+Semantic Highlighting
+^^^^^^^^^^^^^^^^^^^^^
+
+Compile flags
+^^^^^^^^^^^^^
+
+Hover
+^^^^^
+
+Code completion
+^^^^^^^^^^^^^^^
+
+- Now also provides include files without extension, if they are in a directory
+ only called ``include``.
+
+- Added support for ``InsertReplaceEdit`` in code completion (LSP 3.16),
+ allowing clients that advertise ``insertReplaceSupport`` to receive both
+ insert and replace ranges for completion items.
+
+- Changed completion-style default to ``detailed``. This means function
+ overloads will no longer be bundled together, but instead each have
+ their own completion item. This gives the user a better overview of the
+ possible overloads and also when accepting the item it will generate
+ placeholder parameters, which was not possible due to ambiguity with
+ ``bundled``. To change back to the old behaviour, pass the argument
+ ``--completion-style=bundled`` to clangd.
+
+Code actions
+^^^^^^^^^^^^
+
+- A new tweak "Create function body out-of-line" was added that creates
+ an implementation for a function declaration.
+
+Signature help
+^^^^^^^^^^^^^^
+
+Cross-references
+^^^^^^^^^^^^^^^^
+
+Objective-C
+^^^^^^^^^^^
+
+Miscellaneous
+^^^^^^^^^^^^^
+
+Improvements to clang-doc
+-------------------------
+
+Improvements to clang-query
+---------------------------
+
+Improvements to clang-tidy
+--------------------------
+
+- Improved :program:`check_clang_tidy.py` script by adding the `-check-header`
+ argument to simplify testing of header files. This argument automatically
+ manages the creation of temporary header files and ensures that diagnostics
+ and fixes are verified for the specified headers.
+
+- Improved :program:`clang-tidy` ``-store-check-profile`` by generating valid
+ JSON when the source file path contains characters that require JSON escaping.
+
+- Added support for specifying ``LineFilter`` in :program:`clang-tidy`
+ configuration files. This is particularly useful for tools such as
+ :program:`clangd` that consume ``.clang-tidy`` files directly.
+
+- Ensured that :program:`clang-tidy` and the clang compiler uses the same logic
+ for the suppression of compiler diagnostics in system headers and expansions
+ of macros defined in system headers. Previously the default setting of tidy
+ overzealously suppressed some diagnostics that would have been emitted by the
+ compiler. (E.g. tidy suppressed many ``clang-diagnostic-invalid-offsetof``
+ reports because they usually occur in expansion of the macro ``offsetof``.)
+
+- :program:`clang-tidy` will no longer exit immediately if the only enabled
+ checks are `clang-diagnostic-*` ones. This allows using
+ :program:`clang-tidy` purely as a frontend to Clang's builtin warnings.
+
+New checks
+^^^^^^^^^^
+
+- New :doc:`bugprone-assignment-in-selection-statement
+ <clang-tidy/checks/bugprone/assignment-in-selection-statement>` check.
+
+ Finds assignments within selection statements.
+
+- New :doc:`bugprone-missing-end-comparison
+ <clang-tidy/checks/bugprone/missing-end-comparison>` check.
+
+ Finds instances where the result of a standard algorithm is used in a Boolean
+ context without being compared to the end iterator.
+
+- New :doc:`bugprone-unsafe-to-allow-exceptions
+ <clang-tidy/checks/bugprone/unsafe-to-allow-exceptions>` check.
+
+ Finds functions where throwing exceptions is unsafe but the function is still
+ marked as potentially throwing.
+
+- New :doc:`llvm-formatv-string
+ <clang-tidy/checks/llvm/formatv-string>` check.
+
+ Validates ``llvm::formatv`` format strings against the provided arguments,
+ diagnosing mismatched argument counts, unused arguments, and mixed index styles.
+
+- New :doc:`llvm-redundant-casting
+ <clang-tidy/checks/llvm/redundant-casting>` check.
+
+ Points out uses of ``cast<>``, ``dyn_cast<>`` and their ``or_null`` variants
+ that are unnecessary because the argument already is of the target type, or a
+ derived type thereof. Also does similar analysis for calls to ``isa<>`` that
+ always return ``true``.
+
+- New :doc:`llvm-type-switch-case-types
+ <clang-tidy/checks/llvm/type-switch-case-types>` check.
+
+ Finds ``llvm::TypeSwitch::Case`` calls with redundant explicit template
+ arguments that can be inferred from the lambda parameter type.
+
+- New :doc:`llvm-use-vector-utils
+ <clang-tidy/checks/llvm/use-vector-utils>` check.
+
+ Finds calls to ``llvm::to_vector(llvm::map_range(...))`` and
+ ``llvm::to_vector(llvm::make_filter_range(...))`` that can be replaced with
+ ``llvm::map_to_vector`` and ``llvm::filter_to_vector``.
+
+- New :doc:`misc-static-initialization-cycle
+ <clang-tidy/checks/misc/static-initialization-cycle>` check.
+
+ Finds cyclical initialization of static variables.
+
+- New :doc:`modernize-use-std-bit
+ <clang-tidy/checks/modernize/use-std-bit>` check.
+
+ Finds common idioms which can be replaced by standard functions from the
+ ``<bit>`` C++20 header.
+
+- New :doc:`modernize-use-string-view
+ <clang-tidy/checks/modernize/use-string-view>` check.
+
+ Looks for functions returning ``std::[w|u8|u16|u32]string`` and suggests to
+ change it to ``std::[...]string_view`` for performance reasons if possible.
+
+- New :doc:`modernize-use-structured-binding
+ <clang-tidy/checks/modernize/use-structured-binding>` check.
+
+ Finds places where structured bindings could be used to decompose pairs and
+ suggests replacing them.
+
+- New :doc:`performance-string-view-conversions
+ <clang-tidy/checks/performance/string-view-conversions>` check.
+
+ Finds and removes redundant conversions from ``std::[w|u8|u16|u32]string_view`` to
+ ``std::[...]string`` in call expressions expecting ``std::[...]string_view``.
+
+- New :doc:`performance-use-std-move
+ <clang-tidy/checks/performance/use-std-move>` check.
+
+ Suggests insertion of ``std::move(...)`` to turn copy assignment operator
+ calls into move assignment ones, when deemed valid and profitable.
+
+- New :doc:`readability-redundant-lambda-parameter-list
+ <clang-tidy/checks/readability/redundant-lambda-parameter-list>` check.
+
+ Finds lambda expressions with a redundant empty parameter list and removes it.
+
+- New :doc:`readability-redundant-qualified-alias
+ <clang-tidy/checks/readability/redundant-qualified-alias>` check.
+
+ Finds redundant identity type aliases that re-expose a qualified name and can
+ be replaced with a ``using`` declaration.
+
+- New :doc:`readability-trailing-comma
+ <clang-tidy/checks/readability/trailing-comma>` check.
+
+ Checks for presence or absence of trailing commas in enum definitions and
+ initializer lists.
+
+New check aliases
+^^^^^^^^^^^^^^^^^
+
+- Renamed :doc:`cert-exp45-c <clang-tidy/checks/cert/exp45-c>`
+ to :doc:`bugprone-assignment-in-selection-statement
+ <clang-tidy/checks/bugprone/assignment-in-selection-statement>`.
+
+- Renamed :doc:`cppcoreguidelines-explicit-constructor
+ <clang-tidy/checks/cppcoreguidelines/explicit-constructor>`
+ to :doc:`misc-explicit-constructor
+ <clang-tidy/checks/misc/explicit-constructor>`. The
+ `cppcoreguidelines-explicit-constructor` name is kept as an alias.
+
+- Renamed :doc:`google-explicit-constructor
+ <clang-tidy/checks/google/explicit-constructor>`
+ to :doc:`misc-explicit-constructor
+ <clang-tidy/checks/misc/explicit-constructor>`. The
+ `google-explicit-constructor` name is kept as an alias.
+
+- Renamed :doc:`performance-faster-string-find
+ <clang-tidy/checks/performance/faster-string-find>` to
+ :doc:`performance-prefer-single-char-overloads
+ <clang-tidy/checks/performance/prefer-single-char-overloads>`.
+ The `performance-faster-string-find` name is kept as an alias.
+
+Changes in existing checks
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Improved :doc:`altera-id-dependent-backward-branch
+ <clang-tidy/checks/altera/id-dependent-backward-branch>` check by fixing false
+ positives when ordinary variable or field assignments are used in loop
+ conditions and note locations for inferred ID-dependent fields.
+
+- Improved :doc:`bugprone-argument-comment
+ <clang-tidy/checks/bugprone/argument-comment>`:
+
+ - Checks for C++11 inherited constructors.
+
+ - Adds `CommentAnonymousInitLists`, `CommentTypedInitLists`, and
+ `CommentParenthesizedTemporaries` options to comment braced-init list
+ arguments and explicit temporary constructions (for example, ``{}``,
+ ``Type{}``, and ``Type()``).
+
+- Improved :doc:`bugprone-bad-signal-to-kill-thread
+ <clang-tidy/checks/bugprone/bad-signal-to-kill-thread>` check by fixing false
+ negatives when the ``SIGTERM`` macro is obtained from a precompiled header.
+
+- Improved :doc:`bugprone-casting-through-void
+ <clang-tidy/checks/bugprone/casting-through-void>` check by running only on
+ C++ files because suggested ``reinterpret_cast`` is not available in pure C.
+
+- Improved :doc:`bugprone-derived-method-shadowing-base-method
+ <clang-tidy/checks/bugprone/derived-method-shadowing-base-method>` check by
+ correctly ignoring function templates.
+
+- Improved :doc:`bugprone-exception-escape
+ <clang-tidy/checks/bugprone/exception-escape>` check by adding
+ `TreatFunctionsWithoutSpecificationAsThrowing` option to support reporting
+ for unannotated functions, enabling reporting when no explicit ``throw``
+ is seen and allowing separate tuning for known and unknown implementations.
+
+- Improved :doc:`bugprone-fold-init-type
+ <clang-tidy/checks/bugprone/fold-init-type>` check by detecting precision
+ loss in overloads with transparent standard functors (e.g. ``std::plus<>``)
+ for ``std::accumulate``, ``std::reduce``, and ``std::inner_product``.
+
+- Improved :doc:`bugprone-inc-dec-in-conditions
+ <clang-tidy/checks/bugprone/inc-dec-in-conditions>` check by fixing a false
+ positive when increment/decrement operators appear inside lambda bodies that
+ are part of a condition expression.
+
+- Improved :doc:`bugprone-incorrect-enable-if
+ <clang-tidy/checks/bugprone/incorrect-enable-if>` check to not
+ insert an extraneous ``typename`` on code like
+ ``typename std::enable_if<...>``, where there's already a ``typename`` and
+ only the ``::type`` at the end is missing.
+
+- Improved :doc:`bugprone-macro-parentheses
+ <clang-tidy/checks/bugprone/macro-parentheses>` check by printing the macro
+ definition in the warning message if the macro is defined on command line.
+
+- Improved :doc:`bugprone-move-forwarding-reference
+ <clang-tidy/checks/bugprone/move-forwarding-reference>` check by fixing some
+ false positives in the context of moved lambda captures.
+
+- Improved :doc:`bugprone-narrowing-conversions
+ <clang-tidy/checks/bugprone/narrowing-conversions>` check by fixing a false
+ positive when converting a ``bool`` to a signed integer type.
+
+- Improved :doc:`bugprone-pointer-arithmetic-on-polymorphic-object
+ <clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object>` check
+ by fixing a false positive when ``operator[]`` is used in a dependent context.
+
+- Improved :doc:`bugprone-random-generator-seed
+ <clang-tidy/checks/bugprone/random-generator-seed>` check by adding
+ a new note at the location of the field if the generator is implicitly
+ initialized with a default seed value.
+
+- Improved :doc:`bugprone-std-namespace-modification
+ <clang-tidy/checks/bugprone/std-namespace-modification>` check by fixing
+ false positives when extending the standard library with a specialization of
+ user-defined type and by removing detection of the compiler generated ``std``
+ namespace extensions.
+
+- Improved :doc:`bugprone-string-constructor
+ <clang-tidy/checks/bugprone/string-constructor>` check to detect suspicious
+ string constructor calls when the string class constructor has a default
+ allocator argument.
+
+- Improved :doc:`bugprone-throwing-static-initialization
+ <clang-tidy/checks/bugprone/throwing-static-initialization>` check by adding
+ the `AllowedTypes` option. With this option it is possible to exclude
+ static declarations with specific types from the check.
+
+- Improved :doc:`bugprone-unchecked-optional-access
+ <clang-tidy/checks/bugprone/unchecked-optional-access>` to recognize common
+ GoogleTest macros such as ``ASSERT_TRUE`` and ``ASSERT_FALSE``, reducing the
+ number of false positives in test code.
+
+- Improved :doc:`bugprone-unsafe-functions
+ <clang-tidy/checks/bugprone/unsafe-functions>` check by adding the function
+ ``std::get_temporary_buffer`` to the default list of unsafe functions. (This
+ function is unsafe, useless, deprecated in C++17 and removed in C++20).
+
+- Improved :doc:`bugprone-use-after-move
+ <clang-tidy/checks/bugprone/use-after-move>` check:
+
+ - Include the name of the invalidating function in the warning message when a
+ custom invalidation function is used (via the `InvalidationFunctions`
+ option).
+
+ - Add support for annotation of user-defined types as having the same
+ moved-from semantics as standard smart pointers.
+
+ - Do not report explicit call to destructor after move as an invalid use.
+
+ - Avoid false positives when moving object to a base type then accessing
+ non-base members.
+
+ - Avoid false positives when moving object is reinitialized via the base
+ class's ``operator=``.
+
+ - Fix a false positive when a moved-from variable is reinitialized
+ via a ``std::tie()`` assignment (e.g. ``std::tie(a, b) = f(std::move(a),
+ std::move(b))``). The tuple assignment writes back through the stored
+ references, which fully reinitializes the captured variables.
+
+- Improved :doc:`cert-err33-c
+ <clang-tidy/checks/cert/err33-c>` check by not inheriting
+ `CheckedReturnTypes` option from :doc:`bugprone-unused-return-value
+ <clang-tidy/checks/bugprone/unused-return-value>`, which caused false
+ positives on functions returning ``std::error_code`` or similar types.
+
+- Improved :doc:`cppcoreguidelines-avoid-capturing-lambda-coroutines
+ <clang-tidy/checks/cppcoreguidelines/avoid-capturing-lambda-coroutines>`
+ check by adding the `AllowExplicitObjectParameters` option. When enabled,
+ lambda coroutines using C++23 deducing ``this`` (explicit object parameter)
+ are not flagged.
+
+- Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
+ <clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables>`
+ check by adding the `IgnoreMacros` option. When enabled, non-const global
+ variables defined in macros are ignored.
+
+- Improved :doc:`cppcoreguidelines-init-variables
+ <clang-tidy/checks/cppcoreguidelines/init-variables>` check by ensuring that
+ member pointers are correctly flagged as uninitialized.
+
+- Fixed :doc:`cppcoreguidelines-init-variables
+ <clang-tidy/checks/cppcoreguidelines/init-variables>` check by excluding
+ Objective-C for-in loop variable declaration.
+
+- Improved :doc:`cppcoreguidelines-missing-std-forward
+ <clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by:
+
+ - Correctly handling forwarding in deeply nested lambdas.
+
+ - Fixed false negative when multiple parameters are used in a lambda and
+ only some of them are forwarded.
+
+ - Fixed false positive for constrained template parameters
+
+ - Fixed false positive with ``std::forward`` in brace-init and paren-init
+ lambda captures such as ``[t{std::forward<T>(t)}]``.
+
+- Improved :doc:`cppcoreguidelines-pro-type-member-init
+ <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` check by fixing
+ a false positive when a base class has a forward declaration before its
+ definition.
+
+- Improved :doc:`cppcoreguidelines-pro-type-vararg
+ <clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check by no longer
+ warning on builtins with custom type checking (e.g., type-generic builtins
+ like ``__builtin_clzg``) that use variadic declarations as an implementation
+ detail.
+
+- Improved :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
+ <clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved>` check
+ by fixing a false positive on implicitly generated functions such as
+ inherited constructors.
+
+- Improved :doc:`cppcoreguidelines-use-enum-class
+ <clang-tidy/checks/cppcoreguidelines/use-enum-class>` check by adding the
+ `IgnoreMacros` option. When enabled, unscoped ``enum`` declarations within
+ macros are ignored.
+
+- Improved :doc:`fuchsia-statically-constructed-objects
+ <clang-tidy/checks/fuchsia/statically-constructed-objects>` check by fixing a
+ crash when checking value-dependent static member initializers in class templates.
+
+- Improved :doc:`llvm-use-ranges
+ <clang-tidy/checks/llvm/use-ranges>` check by adding support for the following
+ algorithms: ``std::accumulate``, ``std::replace_copy``, and
+ ``std::replace_copy_if``.
+
+- Improved :doc:`misc-const-correctness
+ <clang-tidy/checks/misc/const-correctness>` check:
+
+ - Added support for analyzing function parameters with the `AnalyzeParameters`
+ option.
+
+ - Fixed false positive where an array of pointers to ``const`` was
+ incorrectly diagnosed as allowing the pointee to be made ``const``.
+
+ - Fixed false positive where a pointer used with placement new was
+ incorrectly diagnosed as allowing the pointee to be made ``const``.
+
+ - Fixed false positive where calling a non-const member function on a
+ pointer was incorrectly treated as mutating the pointer, when it only
+ mutates the pointee.
+
+ - Fixed false positives when pointers were later passed or bound through
+ ``const``-qualified pointer references.
+
+- Improved :doc:`misc-multiple-inheritance
+ <clang-tidy/checks/misc/multiple-inheritance>` by avoiding false positives when
+ virtual inheritance causes concrete bases to be counted more than once.
+
+- Improved :doc:`misc-redundant-expression
+ <clang-tidy/checks/misc/redundant-expression>` check by fixing a crash when
+ evaluating bitwise comparisons against integer constants wider than 64 bits.
+
+- Improved :doc:`misc-throw-by-value-catch-by-reference
+ <clang-tidy/checks/misc/throw-by-value-catch-by-reference>` check:
+
+ - Fixed the `WarnOnLargeObject` option to use the correct name when
+ storing the configuration.
+
+ - Fixed the `CheckThrowTemporaries` option to correctly reflect its
+ configured value in exported settings.
+
+- Improved :doc:`misc-unused-parameters
+ <clang-tidy/checks/misc/unused-parameters>` check by adding
+ `IgnoreMacroParameters` option to suppress warnings for unused parameters
+ whose declarations originate from macro expansions.
+
+- Improved :doc:`misc-unused-using-decls
+ <clang-tidy/checks/misc/unused-using-decls>` to not diagnose ``using``
+ declarations as unused if they're exported from a module.
+
+- Improved :doc:`misc-use-internal-linkage
+ <clang-tidy/checks/misc/use-internal-linkage>` to not suggest giving
+ internal linkage to entities defined in C++ module interface units.
+ Because it only sees one file at a time, the check can't be sure
+ such entities aren't referenced in any other files of that module.
+
+- Improved :doc:`modernize-deprecated-headers
+ <clang-tidy/checks/modernize/deprecated-headers>` check by avoiding false
+ positives on project headers that use the same name as a standard library
+ header.
+
+- Improved :doc:`modernize-macro-to-enum
+ <clang-tidy/checks/modernize/macro-to-enum>` check by preserving source file
+ line endings in fix-it replacements.
+
+- Improved :doc:`modernize-pass-by-value
+ <clang-tidy/checks/modernize/pass-by-value>` check by adding `IgnoreMacros`
+ option to suppress warnings in macros.
+
+- Improved :doc:`modernize-redundant-void-arg
+ <clang-tidy/checks/modernize/redundant-void-arg>` check to work in C23.
+
+- Improved :doc:`modernize-return-braced-init-list
+ <clang-tidy/checks/modernize/return-braced-init-list>` check to apply fix-it
+ when type qualifiers and/or reference modifiers are used with parameters.
+
+- Improved :doc:`modernize-use-default-member-init
+ <clang-tidy/checks/modernize/use-default-member-init>` check by fixing a
+ false positive when a constructor initializer refers to a declaration that
+ would not be visible from the inserted default member initializer. The
+ `IgnoreNonVisibleReferences` option can be set to `false` to warn without
+ emitting fix-its for these cases.
+
+- Improved :doc:`modernize-use-equals-delete
+ <clang-tidy/checks/modernize/use-equals-delete>` check by only warning on
+ private deleted functions, if they do not have a public overload or are a
+ special member function.
+
+- Improved :doc:`modernize-use-nodiscard
+ <clang-tidy/checks/modernize/use-nodiscard>` check by avoiding false
+ positives on functions returning specializations of class templates marked
+ ``[[nodiscard]]``.
+
+- Improved :doc:`modernize-use-ranges
+ <clang-tidy/checks/modernize/use-ranges>` check:
+
+ - Preserved used iterator results when replacing ``std::unique`` calls with
+ ``std::ranges::unique``.
+
+ - Preserved used iterator results when replacing ``std::remove``,
+ ``std::remove_if``, ``std::partition``, ``std::stable_partition``, and
+ ``std::rotate`` calls with their ``std::ranges`` counterparts.
+
+- Improved :doc:`modernize-use-std-format
+ <clang-tidy/checks/modernize/use-std-format>` check:
+
+ - Fixed a crash when an argument is part of a macro expansion.
+
+ - Added missing ``#include`` insertion when the format function call
+ appears as an argument to a macro.
+
+- Improved :doc:`modernize-use-std-print
+ <clang-tidy/checks/modernize/use-std-print>` check by adding missing
+ ``#include`` insertion when the format function call appears as an
+ argument to a macro.
+
+- Improved :doc:`modernize-use-trailing-return-type
+ <clang-tidy/checks/modernize/use-trailing-return-type>` check by fixing
+ spurious ``missing '(' after '__has_feature'`` errors caused by builtin
+ macros appearing in the return type of a function.
+
+- Improved :doc:`modernize-use-using
+ <clang-tidy/checks/modernize/use-using>` check:
+
+ - Avoid generating invalid code for function types with redundant
+ parentheses.
+
+ - Preserve inline comment blocks that appear between the ``typedef``'s parts.
+
+ - The `IgnoreExternC` option is now set to `true` by default.
+
+- Improved :doc:`performance-enum-size
+ <clang-tidy/checks/performance/enum-size>` check:
+
+ - Exclude ``enum`` in ``extern "C"`` blocks.
+
+ - Improved the ignore list to correctly handle ``typedef`` and ``enum``.
+
+- Improved :doc:`performance-inefficient-string-concatenation
+ <clang-tidy/checks/performance/inefficient-string-concatenation>` check by
+ adding support for detecting inefficient string concatenation in ``do-while``
+ loops.
+
+- Improved :doc:`performance-inefficient-vector-operation
+ <clang-tidy/checks/performance/inefficient-vector-operation>` check by
+ correctly handling vector-like classes when ``push_back``/``emplace_back`` are
+ inherited.
+
+- Improved :doc:`performance-move-const-arg
+ <clang-tidy/checks/performance/move-const-arg>` check by avoiding false
+ positives on trivially copyable types with a non-public copy constructor.
+
+- Improved :doc:`performance-prefer-single-char-overloads
+ <clang-tidy/checks/performance/prefer-single-char-overloads>` check:
+
+ - Now analyzes calls to the ``starts_with``, ``ends_with``, ``contains``,
+ and ``operator+=`` string member functions.
+
+ - Fixes false negatives when using ``std::set`` from ``libstdc++``.
+
+- Improved :doc:`performance-trivially-destructible
+ <clang-tidy/checks/performance/trivially-destructible>` check by fixing
+ false positives when a class is seen through both a header include and
+ a C++20 module import.
+
+- Improved :doc:`readability-braces-around-statements
+ <clang-tidy/checks/readability/braces-around-statements>` check by fixing a
+ crash when diagnosing a statement that ends in the middle of a macro body
+ expansion.
+
+- Improved :doc:`readability-container-size-empty
+ <clang-tidy/checks/readability/container-size-empty>` check:
+
+ - Fix a crash when a member expression has a non-identifier name.
+
+ - Reduce verbosity by removing the note indicating source location of the
+ ``empty`` function.
+
+ - Fixed a false positive with suggesting ``empty`` when comparing a container
+ to a default-constructed object of an unrelated type.
+
+ - Extended to warn when the non-member ``std::size()`` function is used
+ in a Boolean context or compared to ``0`` or ``1``, consistent with the
+ existing ``size()``/``length()`` member call detection.
+
+- Improved :doc:`readability-convert-member-functions-to-static
+ <clang-tidy/checks/readability/convert-member-functions-to-static>` check:
+
+ - Fixing a false positive where ``const`` member functions were incorrectly
+ flagged when they are part of a const/non-const overload pair.
+
+ - Correctly detecting ``this`` usage when a generic lambda calls an overloaded
+ member function.
+
+- Improved :doc:`readability-else-after-return
+ <clang-tidy/checks/readability/else-after-return>` check:
+
+ - Fixed missed diagnostics when ``if`` statements appear in unbraced
+ ``switch`` case labels.
+
+ - Fixed a false positive involving ``if`` statements which contain
+ a ``return``, ``break``, etc., jumped over by a ``goto``.
+
+ - Fixed the check potentially breaking code by deleting one too many
+ characters following an ``else`` or a curly brace.
+
+ - Added support for handling attributed ``if`` then-branches such as
+ ``[[likely]]`` and ``[[unlikely]]``.
+
+ - Diagnose and remove redundant ``else`` branches after calls to
+ ``[[noreturn]]`` functions.
+
+- Improved :doc:`readability-enum-initial-value
+ <clang-tidy/checks/readability/enum-initial-value>` check: the warning message
+ now uses separate note diagnostics for each uninitialized enumerator, making
+ it easier to see which specific enumerators need explicit initialization.
+
+- Improved :doc:`readability-function-size
+ <clang-tidy/checks/readability/function-size>` check by adding an
+ `IgnoreMacros` option to exclude statements, branches, nesting levels, and
+ variable declarations inside macros from the reported metrics.
+
+- Improved :doc:`readability-identifier-length
+ <clang-tidy/checks/readability/identifier-length>` check:
+
+ - A new option, named `LineCountThreshold`, is added to silence warnings for
+ short-lived variables, based on distance between declaration and last use.
+
+ - Support for structured bindings is added. Two new options, named
+ `MinimumBindingNameLength` and `IgnoredBindingNames` respectively, are
+ added to configure the behavior of the check regarding this new identifier
+ kind. By default, names with at least 2 characters are required and the
+ only exception allowed is `_`.
+
+- Improved :doc:`readability-identifier-naming
+ <clang-tidy/checks/readability/identifier-naming>` check:
+
+ - Fixed incorrect naming style application to C++17 structured bindings.
+
+ - Fixed a false positive where function templates could be diagnosed as generic
+ identifiers when `DefaultCase` was enabled.
+
+- Improved :doc:`readability-implicit-bool-conversion
+ <clang-tidy/checks/readability/implicit-bool-conversion>` check:
+
+ - Fixed a false positive where `AllowPointerConditions` and
+ `AllowIntegerConditions` options did not suppress warnings when the
+ condition expression involved temporaries (e.g. passing a string literal to
+ a ``const std::string&`` parameter).
+
+ - Warn and provide fix-its when a macro defined in a system header (e.g.
+ ``NULL``) is implicitly converted to ``bool``.
+
+ - Added `AllowLogicalOperatorConversion` option to suppress warnings on
+ implicit conversions of logical operator results (``&&``, ``||``, ``!``)
+ to ``bool`` in C.
+
+ - Fixed a false positive where ``bool`` conditions in C conditional
+ operators were diagnosed as implicit conversions to ``int``.
+
+- Improved :doc:`readability-non-const-parameter
+ <clang-tidy/checks/readability/non-const-parameter>` check:
+
+ - Avoid false positives on parameters used in dependent expressions
+ (e.g. inside generic lambdas), including constructor-style dependent initializers.
+
+ - Fixed a false positive in array subscript expressions where the types are
+ not yet resolved.
+
+ - Fixed a crash when analyzing a redeclaration whose initializer is attached
+ to another declaration.
+
+- Improved :doc:`readability-redundant-casting
+ <clang-tidy/checks/readability/redundant-casting>` check by adding the
+ `IgnoreImplicitCasts` option (default `false`) to flag casts as redundant
+ when at least one operand of a binary operation matches the cast type due to
+ implicit conversion. For example, ``static_cast<float>(1.0f + 1)`` is now
+ identified as redundant since ``1`` is implicitly converted to ``float``.
+ Setting this option to `true` restores the previous behavior.
+
+- Improved :doc:`readability-redundant-member-init
+ <clang-tidy/checks/readability/redundant-member-init>` check by adding an
+ `IgnoreMacros` option to suppress warnings when the initializer involves
+ macros that may expand differently in other configurations.
+
+- Improved :doc:`readability-redundant-parentheses
+ <clang-tidy/checks/readability/redundant-parentheses>` check by fixing a
+ false positive for parentheses present around an overloaded operator in the
+ context of a binary operation.
+
+- Improved :doc:`readability-redundant-preprocessor
+ <clang-tidy/checks/readability/redundant-preprocessor>` check by fixing a
+ false positive for nested ``#if`` directives using different builtin
+ expressions such as ``__has_builtin`` and ``__has_cpp_attribute``.
+
+- Improved :doc:`readability-simplify-boolean-expr
+ <clang-tidy/checks/readability/simplify-boolean-expr>` check to provide valid
+ fix suggestions for C23 and later by not using ``static_cast``.
+
+- Improved :doc:`readability-simplify-subscript-expr
+ <clang-tidy/checks/readability/simplify-subscript-expr>` check by fixing
+ missing warnings when subscripting an object held inside a generic
+ container (e.g. subscripting a ``std::string`` held inside a
+ ``std::vector<std::string>``).
+
+- Improved :doc:`readability-suspicious-call-argument
+ <clang-tidy/checks/readability/suspicious-call-argument>` check by avoiding a
+ crash from invalid ``Abbreviations`` option.
+
+- Improved :doc:`readability-use-anyofallof
+ <clang-tidy/checks/readability/use-anyofallof>` check by emitting a diagnostic
+ note to suggest materializing the temporary range when iterating over temporary
+ range expressions or initializer lists, as reusing them directly could be unsafe.
+
+Removed checks
+^^^^^^^^^^^^^^
+
+Miscellaneous
+^^^^^^^^^^^^^
+
+Improvements to include-fixer
+-----------------------------
+
+Improvements to clang-include-fixer
+-----------------------------------
+
+- Fixed crashes when command-line argument parsing failed at unknown tool options.
+
+Improvements to modularize
+--------------------------
+
+Improvements to pp-trace
+------------------------
+
+Clang-tidy Visual Studio plugin
+-------------------------------
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/line-filter-config.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/line-filter-config.cpp
new file mode 100644
index 0000000000000..5a79ba2f39012
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/line-filter-config.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-tidy -checks='-*,modernize-use-using' -config="{LineFilter: [{name: 'line-filter-config.cpp', lines: [[8, 8]]}]}" %s -- 2>&1 | FileCheck --check-prefix=CONFIG %s
+// RUN: clang-tidy -checks='-*,modernize-use-using' -config="{LineFilter: [{name: 'line-filter-config.cpp', lines: [[8, 8]]}]}" -line-filter="[{name: 'line-filter-config.cpp', lines: [[12, 12]]}]" %s -- 2>&1 | FileCheck --check-prefix=CLI %s
+
+typedef int BeforeLineFilter;
+// CONFIG-NOT: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CLI-NOT: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+
+typedef int ConfigWarn;
+// CONFIG: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
+// CLI-NOT: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
+
+typedef int CliWarn;
+// CONFIG-NOT: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CLI: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
+
+typedef int AfterLineFilter;
+// CONFIG-NOT: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CLI-NOT: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
index 3f86f65c1ce65..78e3f7abd2d70 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -75,6 +75,21 @@ TEST(ParseLineFilter, ValidFilter) {
EXPECT_EQ(1000u, Options.LineFilter[2].LineRanges[0].second);
}
+TEST(ClangTidyOptions, PassesLineFilter) {
+ EXPECT_TRUE(passesLineFilter({}, "a.cpp", 1));
+
+ std::vector<FileFilter> Filters = {{"file.cpp", {{10, 12}, {20, 20}}}};
+ EXPECT_TRUE(passesLineFilter(Filters, "/path/file.cpp", 10));
+ EXPECT_TRUE(passesLineFilter(Filters, "/path/file.cpp", 12));
+ EXPECT_TRUE(passesLineFilter(Filters, "/path/file.cpp", 20));
+ EXPECT_FALSE(passesLineFilter(Filters, "/path/file.cpp", 13));
+ EXPECT_FALSE(passesLineFilter(Filters, "/path/other.cpp", 10));
+
+ Filters = {{"header.h", {}}};
+ EXPECT_TRUE(passesLineFilter(Filters, "/path/header.h", 999));
+ EXPECT_FALSE(passesLineFilter(Filters, "/path/file.cpp", 1));
+}
+
TEST(ParseConfiguration, ValidConfiguration) {
llvm::ErrorOr<ClangTidyOptions> Options =
parseConfiguration(llvm::MemoryBufferRef(
More information about the cfe-commits
mailing list