[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable
Michael Benfield via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 28 13:24:26 PDT 2021
mbenfield added a comment.
So it seems there are 3 issues here:
1. local variables declared extern should not trigger this warning. I'll fix this.
2. Should `x` in this code trigger the warning:
int x;
int y = (x = 0);
These are essentially the "false positives" reported in the Linux kernel. I find it questionable to consider these "false positives"; it seems to me that `x` is not really used. But gcc's behavior is to not trigger here so maybe following it is best.
3. If `x` above should not trigger the warning, it might be difficult to detect this case with an AST walk using the current data. Would it be acceptable to add a bit to `VarDecl` or `Decl` indicating whether it's ever //read// (not just referenced), which could then be set, maybe in `Sema::ActOnFinishFullExpr` ? This would then prevent the need for the new AST walk altogether. (it seems gcc has such a bit)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100581/new/
https://reviews.llvm.org/D100581
More information about the cfe-commits
mailing list