[clang-tools-extra] [clang-tidy] Adds readability-redundant-const check (PR #189733)

Berkay Sahin via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 12 06:46:43 PDT 2026


berkaysahiin wrote:

> Can we add test with multiple decls: `constexpr const int a = 1, b = 2` and mixes like `constexpr const int a = 0, &b = a;`. For latter case we can't remove const, but we can give only warning with no fixit.
> 
> Did you try to test the check against some codebases (like LLVM). If not, please try to do so to find any FP/FN beforehand.
> 
> Otherwise LGTM.

Check currently fails at

```cpp
constexpr const int a = 0, &b = a;
```

where it matches `a` and suggests removal of `const`.

I have added `hasProblemSibling` to look for decls within the same statements and not offer fixit if any neighbor decl is typed either pointer or reference.

Let me know what you think. @vbvictor 

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


More information about the cfe-commits mailing list