[clang-tools-extra] [clang-tidy] Add new check 'misc-scope-reduction' (PR #175429)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 11 07:14:25 PST 2026


https://github.com/zwuis commented:

If AI was used, please disclose it. And to what extent it was used.

---

Please remove unnecessary comment such as `// early exit`.

---

>From #22366, I think there is another option for the name of this check: misc-localizing-variables. But I'm neutral with these names.

What about put this check in "readability" module instead of "misc"?

---

I wonder if we can use `RecursiveASTVisitor`/`DynamicRecursiveASTVisitor` to find the innermost scope containing all `DeclRefExpr`.

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


More information about the cfe-commits mailing list