[clang-tools-extra] [clang-tidy][readability-identifier-length] add structured bindings support (PR #193838)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 24 09:39:36 PDT 2026
================
@@ -145,7 +158,26 @@ void IdentifierLengthCheck::check(const MatchFinder::MatchResult &Result) {
<< 0 << StandaloneVar << MinimumVariableNameLength;
}
- auto *ExceptionVarName = Result.Nodes.getNodeAs<VarDecl>("exceptionVar");
+ const auto *BindingVar = Result.Nodes.getNodeAs<ValueDecl>("bindingVar");
+ if (BindingVar) {
+ if (!BindingVar->getIdentifier())
+ return;
+
+ const StringRef VarName = BindingVar->getName();
+
+ if (VarName.size() >= MinimumBindingNameLength ||
+ IgnoredBindingNames.match(VarName))
+ return;
+
+ if (isShortLived(BindingVar, Result.SourceManager, Result.Context,
+ LineCountThreshold))
+ return;
+
+ diag(BindingVar->getLocation(), ErrorMessage)
+ << 1 << BindingVar << MinimumBindingNameLength;
+ }
----------------
localspook wrote:
If you could, that would be great!
https://github.com/llvm/llvm-project/pull/193838
More information about the cfe-commits
mailing list