Issue 184330
Summary [clang-tidy] misc-const-correctness should not warn about unnamed parameters
Labels enhancement, clang-tidy
Assignees
Reporter carlosgalvezp
    Example:

```cpp
void foo(int&)
{
    // TODO: implement
}

void foo(float& x)
{
    x = 1.23F;
}
```
```
source>:1:10: warning: variable '' of type 'int &' can be declared 'const' [misc-const-correctness]
    1 | void foo(int&)
      | ^  
      |              const
1 warning generated.
```

[Godbolt](https://godbolt.org/z/zaavKKn3n).

While the check may be technically correct, it's not very useful. It does not make sense to mark the parameter `const` only to remove it later when the function is implemented. It may not even be possible at all to mark it as `const` when having e.g. generic code that operates on both `int` and `float`.

It would be good if the check would ignore unnamed parameters. This is a common pattern when implementing some interface and some of the parameters are not used.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to