[clang-tools-extra] [clang-tidy] make `misc-const-correctness` work with `auto` variables and lambdas (PR #157319)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 3 05:21:52 PST 2025


vbvictor wrote:

To sum up my concerns, I think we can have a temporary option for checking `auto` types (to smooth transitions) but I wish we have persistent option to exclude lambdas because AFAIK they are immutable anyway: https://godbolt.org/z/YxY96784z.
```cpp
int main() {
    auto Lambda = [](int i) { return i < 0; }; 
    Lambda = [](int i) { return i < 0; }; // error: no viable overloaded '='
}
```
So there is no point to make lambdas `const` and I think that people would not want to modify whole codebase for 0 benefit of "const lambdas". Or is there a way to assign lambda variable twise?

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


More information about the cfe-commits mailing list