| Issue |
203909
|
| Summary |
[clang-tidy] Improvement on 'misc-unused-parameters' check
|
| Labels |
|
| Assignees |
|
| Reporter |
capitan-davide
|
In MISRA C++:2023, Rule 0.2.2 (A named function parameter shall be used at least once) provides an example like:
```c++
template <bool b>
int f(int i) { // Non-compliant for f<false>
if constexpr (b) {
return i;
}
return 0;
}
```
Should 'misc-unuser-parameters' check detect this condition as well? Currently, [template instantiations are explicitly skipped](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp#L185).
An extension seems straight forward. Looking at the AST, the instantiation of `f<false>` generates a `FunctionDecl` where `IfStmt` has an empty `CompoundStmt`. This means, no `DeclRefExpr` to `i`, so `i` is unused. See https://godbolt.org/z/TfGPx6qE9.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs