[clang-tools-extra] [clang-tidy][readability-identifier-length] Add a line count threshold (PR #185319)

Alex Dutka via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 11 10:05:32 PDT 2026


================
@@ -85,6 +89,41 @@ void IdentifierLengthCheck::registerMatchers(MatchFinder *Finder) {
         this);
 }
 
+static unsigned countLinesToLastUse(const VarDecl *Var,
+                                    const SourceManager *SrcMgr,
+                                    ASTContext *Ctx) {
+  const unsigned DeclLine = SrcMgr->getSpellingLineNumber(Var->getLocation());
+
+  class VarUseCallback : public MatchFinder::MatchCallback {
----------------
dutkalex wrote:

Thanks for the feedback, I did not know about this helper function. I have made the change to use it. Since ``allDeclRefExprs`` does not directly return line numbers, I have used ``std::transform_reduce`` instead of ``max_element``. I'm not 100% sure however if I'm doing the right thing to get the ``Decl*`` representing the parent scope.

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


More information about the cfe-commits mailing list