vbvictor wrote:
> Personally I want to name this check `modernize-unused-variables` to support
>
> * adding `[[maybe_unused]]` instead of renaming the variable to `_`
> (controlled by an option)
> * 'simple' variables
>
> in future.
>
> But, I want fixits to add `[[maybe_unused]]` by default, because
> `[[maybe_unused]]` is introduced earlier and it works with `assert`, so I'd
> like to keep this name and make it an alias in future. (changing default
> fixits is a kind of breaking changes to me)
Do you imagine this case?
```cpp
struct Pair {
int first;
bool second;
};
void referenceBinding() {
Pair p{};
auto &[x, y [[maybe_unused]] ] = p;
use(x);
}
```
It gives:
```
<source>:16:15: warning: an attribute specifier sequence attached to a
structured binding declaration is a C++2c extension [-Wc++26-extensions]
16 | auto &[x, y [[maybe_unused]] ] = p;
|
```
https://godbolt.org/z/13685qc37
I'm happy with modernize-unused-variables naming, since we can provide
different fixits for such declarations.
---------
Overall looks not bad, please add test cases with templates and if possible
test on some projects to find FP/FN/crashes.
https://github.com/llvm/llvm-project/pull/207604
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits