[clang-tools-extra] [clang-tidy] Don't report unnamed params for misc-const-correctness (PR #184388)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 4 04:43:52 PST 2026
================
@@ -207,6 +207,13 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
assert(Variable && LocalScope && Function);
+ // If a variable (e.g. function parameter) is unnamed, don't report it. Being
+ // unnamed already guarantees that the variable can't be accessed, so
+ // 'const'ness (can't be modified) doesn't add extra information. Also, the
+ // messages would be awkward in this case.
+ if (Variable->getDeclName().isIdentifier() && Variable->getName().empty())
----------------
vbvictor wrote:
Hm, thats unfortunate but understandable.
Can we then make a custom `isUnnamed` matcher with `AST_MATCHER()` macro that will essentially do what you wrote inside `check()`. And Leave a `TODO` to merge with `hasName` or move to general matchers as is.
https://github.com/llvm/llvm-project/pull/184388
More information about the cfe-commits
mailing list