[all-commits] [llvm/llvm-project] 0730f6: [clang-tidy] make `misc-const-correctness` work wi...
Victor Chernyakin via All-commits
all-commits at lists.llvm.org
Fri Jul 10 23:54:28 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0730f680b6ac237ee1c81b2c55a741ba7065ee97
https://github.com/llvm/llvm-project/commit/0730f680b6ac237ee1c81b2c55a741ba7065ee97
Author: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: 2026-07-11 (Sat, 11 Jul 2026)
Changed paths:
M clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
M clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-auto-parameters.cpp
A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-auto.cpp
A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-lambdas.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-parameters.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-values.cpp
M clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
Log Message:
-----------
[clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (#157319)
Fixes #60789.
Currently, the check will never make `auto` variables `const`. Here's
the relevant bit of code:
https://github.com/llvm/llvm-project/blob/6b200e21adec0e28407def6fcb2e6c7359fd881b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp#L108-L110
Notice how the matcher's name is `AutoTemplateType`, but it has nothing
to do with templates. What it *was* intended to do, I'm not sure, but
excluding all `auto` variables can't be right.
For lambdas, this is the only justification I can find:
https://github.com/llvm/llvm-project/blob/36627e1724504d783dc1cbc466666516d28260e4/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp#L30-L34
Which doesn't convince me.
Looking at the test changes, I believe there's only one new false
positive, and that one seems to be a symptom of an existing problem that
was only being masked by `auto`, but we can absolutely discuss whether
the now-diagnosed cases are correct.
---------
Co-authored-by: Victor Baranov <bar.victor.2002 at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list