[clang-tools-extra] [clang-tidy][readability-Identifier-length] add structured bindings support (PR #193838)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 14:05:34 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-length-structured-bindings.cpp clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.h clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
index cb7284e1a..8dd238ac8 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
@@ -138,7 +138,8 @@ static bool isShortLived(const ValueDecl *Var, const SourceManager *SrcMgr,
 }
 
 void IdentifierLengthCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *StandaloneVar = Result.Nodes.getNodeAs<ValueDecl>("standaloneVar");
+  const auto *StandaloneVar =
+      Result.Nodes.getNodeAs<ValueDecl>("standaloneVar");
   if (StandaloneVar) {
     if (!StandaloneVar->getIdentifier())
       return;
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index def63f8ac..1a6c922ff 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -366,8 +366,9 @@ bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
   return isSetDifferenceEmpty(AllDeclRefs, ConstReferenceDeclRefs);
 }
 
-SmallPtrSet<const DeclRefExpr *, 16>
-allDeclRefExprs(const ValueDecl &VarDecl, const Stmt &Stmt, ASTContext &Context) {
+SmallPtrSet<const DeclRefExpr *, 16> allDeclRefExprs(const ValueDecl &VarDecl,
+                                                     const Stmt &Stmt,
+                                                     ASTContext &Context) {
   auto Matches = match(
       findAll(declRefExpr(to(valueDecl(equalsNode(&VarDecl)))).bind("declRef")),
       Stmt, Context);
@@ -376,8 +377,9 @@ allDeclRefExprs(const ValueDecl &VarDecl, const Stmt &Stmt, ASTContext &Context)
   return DeclRefs;
 }
 
-SmallPtrSet<const DeclRefExpr *, 16>
-allDeclRefExprs(const ValueDecl &VarDecl, const Decl &Decl, ASTContext &Context) {
+SmallPtrSet<const DeclRefExpr *, 16> allDeclRefExprs(const ValueDecl &VarDecl,
+                                                     const Decl &Decl,
+                                                     ASTContext &Context) {
   auto Matches = match(
       decl(forEachDescendant(
           declRefExpr(to(valueDecl(equalsNode(&VarDecl)))).bind("declRef"))),
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h
index 5aa8f69fc..988fbca66 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.h
@@ -17,11 +17,13 @@ namespace clang::tidy::utils::decl_ref_expr {
 
 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt``.
 llvm::SmallPtrSet<const DeclRefExpr *, 16>
-allDeclRefExprs(const ValueDecl &VarDecl, const Stmt &Stmt, ASTContext &Context);
+allDeclRefExprs(const ValueDecl &VarDecl, const Stmt &Stmt,
+                ASTContext &Context);
 
 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl``.
 llvm::SmallPtrSet<const DeclRefExpr *, 16>
-allDeclRefExprs(const ValueDecl &VarDecl, const Decl &Decl, ASTContext &Context);
+allDeclRefExprs(const ValueDecl &VarDecl, const Decl &Decl,
+                ASTContext &Context);
 
 /// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt`` where
 /// ``VarDecl`` is guaranteed to be accessed in a const fashion.

``````````

</details>


https://github.com/llvm/llvm-project/pull/193838


More information about the cfe-commits mailing list