| Summary: | detect useless overrides | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | Milian Wolff <mail> |
| Component: | general | Assignee: | Unassigned bugs <unassigned-bugs-null> |
| Status: | REPORTED --- | ||
| Severity: | wishlist | CC: | smartins, tu4manjohn |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
(In reply to Milian Wolff from comment #0) > SUMMARY > struct foo { virtual void asdf(); } > struct bar : foo { void asdf() override { foo::asdf(); } } > > The override is completely useless, and I find such code far too often - > could clazy/clang-tidy detect it and remove the useless code? > > it may be problematic to detect when > > - non-trivial arguments are forwarded (still useless) > - Q_UNUSED or similar > - instead of calling the parent implementation, the parent implementation > code is duplicated: > > struct foo { virtual void asdf() { printf("hello"); } > struct bar : foo { void asdf() override { printf("hello"); } } > > OBSERVED RESULT > not detected > > EXPECTED RESULT > useless overrides are marked and offered for automatic removal |
SUMMARY struct foo { virtual void asdf(); } struct bar : foo { void asdf() override { foo::asdf(); } } The override is completely useless, and I find such code far too often - could clazy/clang-tidy detect it and remove the useless code? it may be problematic to detect when - non-trivial arguments are forwarded (still useless) - Q_UNUSED or similar - instead of calling the parent implementation, the parent implementation code is duplicated: struct foo { virtual void asdf() { printf("hello"); } struct bar : foo { void asdf() override { printf("hello"); } } OBSERVED RESULT not detected EXPECTED RESULT useless overrides are marked and offered for automatic removal