Files
Alex Dutka 36990d81d4 [clang-tidy][readability-identifier-length] add structured bindings support (#193838)
This change extends the `readability-identifier-length` check to structured
binding declarations. Currently, only the names of regular variables,
function parameters, exceptions variables in catch blocks and loop
variables are checked. In other words, `int a = ...` warns but `auto [a]
= ...` does not.

This change enables the check to warn when the length of the names
introduced in structured bindings declarations is too short, following
the same rules as for the other kinds of declarations. Two new options
are introduced:
- `MinimumBindingNameLength` defines the number of characters below
which a warning is issued (the default it set to 2, like for loop
variables and exceptions variables)
- `IgnoredBindingNames` defines the names for which warnings should not
issued (by default, `_` is the only allowed exception)

To implement this feature, a new matcher is registered which matches all
the individual binding names. For example, in `auto [x, y] = ...`, it
matches `x` and `y` separately and the logic for determining if a
warning should be issued is applied independently to each binding name
introduced. Unlike the other matchers which return `VarDecl` nodes, this
new matcher returns `BindingDecl` nodes. The `utils::allDeclRefExpr`
helper function is modified to work for any `ValueDecl` node (the
closest common ancestor of `VarDecl` and `BindingDecl`) in order for the
line count threshold feature to work with this extension.
2026-04-27 11:57:03 -07:00
..