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

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 24 17:49:38 PST 2026


================
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+/// \file
+/// This file defines ScopeReductionCheck, a clang-tidy checker that identifies
+/// variables that can be declared in smaller scopes to improve code locality
+/// and readability.
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SCOPEREDUCTIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SCOPEREDUCTIONCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::misc {
+
+/// Detects variables that can be declared in smaller scopes.
+///
+/// This checker analyzes variable declarations and their usage patterns to
----------------
EugeneZelenko wrote:

```suggestion
/// This check analyzes variable declarations and their usage patterns to
```

Same in other places

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


More information about the cfe-commits mailing list