The rational to avoid applying the warning/fix in non-Strict more to
functions with an empty body is that there is "no place for a bug to hide".
However for private functions, the parameters can be entirely eliminated
and all the call sites improved.
Details
- Reviewers
aaron.ballman
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp | ||
---|---|---|
188 | This is looking at the linkage of the function, not at its access control; is that intended? | |
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst | ||
43 | Call sites are not always visible for protected functions, so this seems a bit suspicious. The changes are missing test coverage for that situation. | |
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp | ||
157–159 | I think this demonstrates a bad fix -- this changes code meaning from being a converting constructor to being a default constructor, which are very different things. |
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst | ||
---|---|---|
43 | You're using public for "access control" while I was using the linkage aspect: my reasoning is that if a method isn't "externally visible" from the current translation unit, you see all the call-sites. This is orthogonal to public/private/protected as far as I know. I am likely missing a check for "isDefinedInMainFile" (or whatever the api is called) to not flag included headers. | |
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp | ||
157–159 | Oh you're right: so we can't do it for a Ctor with a single parameter... But we also can't do it for a Ctor with two parameters as it'll turn it into a converting ctor. Unless you can eliminate both parameters, in which case it is become a default ctor (which can conflict with an existing one, in which case it can be just deleted?) |
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst | ||
---|---|---|
43 |
Oh, thanks for pointing out that I was confused! I'm not used to "public" when describing linkage, usually that's "external" or "externally visible". Any appetite for rewording in those terms? Something like "On the other hand, for functions with internal linkage, all the call sites are visible and parameters can be safely removed." | |
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp | ||
157–159 | Yeah, I think we need to not transform ctors at all currently. |
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst | ||
---|---|---|
43 | Sure: happy to reword. (We use public/private for symbol visibility at a module level in MLIR unfortunately, I've been "contaminated" ;) ). | |
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp | ||
157–159 | In this case I can fix the existing bug by disabling the fixit (as discussed in D116513) and abandon this revision I think. |
This is looking at the linkage of the function, not at its access control; is that intended?