[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 15:22:01 PDT 2026
================
@@ -85,6 +90,28 @@ void IdentifierLengthCheck::registerMatchers(MatchFinder *Finder) {
this);
}
+static unsigned countLinesToLastUse(const VarDecl *Var,
+ const SourceManager *SrcMgr,
+ ASTContext *Ctx) {
+ const auto *ParentScope = llvm::dyn_cast<FunctionDecl>(Var->getDeclContext());
+ if (ParentScope == nullptr) {
+ return 1;
+ }
----------------
dutkalex wrote:
It is also my understanding also that this check targets local and global variables. However, global variables can be used across multiple files and in this context, I don't know if it makes sense to try to determine a line of last use. I would argue that this feature should only apply to local variables, and that the check should always warn on globals. What do you think?
https://github.com/llvm/llvm-project/pull/185319
More information about the cfe-commits
mailing list