[PATCH] D116512: [clang-tidy] Limit non-Strict mode to public functions
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 5 06:44:14 PST 2022
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp:188
// (constructor initializer counts for non-empty body).
- if (StrictMode ||
+ if (StrictMode || !Function->isExternallyVisible() ||
(Function->getBody()->child_begin() !=
----------------
This is looking at the linkage of the function, not at its access control; is that intended?
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst:43
+ a human reader, and there's basically no place for a bug to hide. On the other
+ hand for non-public functions, all the call-sites are visible and the parameter
+ can be eliminated entirely.
----------------
Call sites are not always visible for protected functions, so this seems a bit suspicious. The changes are missing test coverage for that situation.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp:157-159
+// CHECK-FIXES: C() {}
+ C(int i) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning
----------------
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.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116512/new/
https://reviews.llvm.org/D116512
More information about the cfe-commits
mailing list