[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 11 14:30:44 PST 2026
================
@@ -9,9 +9,15 @@
template <typename T>
void type_dependent_variables() {
T value = 42;
- auto &ref = value;
T &templateRef = value;
+ auto &ref = value;
+ // CHECK-MESSAGES:[[@LINE-1]]:3: warning: variable 'ref' of type 'int &' can be declared 'const'
+ // CHECK-FIXES: auto const&ref = value;
+ // FIXME: This is a false positive, the reference points to a template type
+ // and needs to be excluded from analysis. See the 'more_template_locals()'
+ // test in 'const-correctness-values.cpp' for more examples of the problem.
----------------
localspook wrote:
To confirm: you're not saying that this problem should be fixed in *this* PR, since this is preexisting?
https://github.com/llvm/llvm-project/pull/157319
More information about the cfe-commits
mailing list