Bug 358519 - rule-of-three: ignore trivial destructors
Summary: rule-of-three: ignore trivial destructors
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-25 07:26 UTC by Nyall Dawson
Modified: 2016-01-25 23:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nyall Dawson 2016-01-25 07:26:02 UTC
The rule of three check should ignore trivial destructors - eg empty destructors
Comment 1 Sergio Martins 2016-01-25 08:07:30 UTC
why do you have an empty dtor ?
Comment 2 Nyall Dawson 2016-01-25 08:17:56 UTC
I'm honestly not sure if there's any good reason for them, but the codebase I'm working on is littered with them. 

Of course, if feel free to close this if you also think there's absolutely no good reason why an empty destructor should be left in a project.
Comment 3 Sergio Martins 2016-01-25 08:38:06 UTC
for virtual classes it's important to have a non-inline dtor, even if empty, for value classes no.
but ok, it reduces the amount of noise, and if it's empty it wouldn't be hiding a bug anyway
Comment 4 Nyall Dawson 2016-01-25 08:40:34 UTC
I wonder if allowing any const calls might work too. This would allow destructors with debugging and other non dangerous code.
Comment 5 Sergio Martins 2016-01-25 08:53:57 UTC
Contributions welcome for Utils::isDangerous(CXXMethodDecl) :)
Comment 6 Sergio Martins 2016-01-25 23:25:36 UTC
Git commit 7947f1ab62801f978557e6ea2f193f07276042a9 by Sergio Martins.
Committed on 25/01/2016 at 23:25.
Pushed by smartins into branch 'master'.

rule-of-three: Allow empty user dtors, for the sake of less noise

If:
- No user copy ctor
- No user copy-assign operator
- User dtor but empty

then we don't warn. Although it violates the rule of the big three it's harmless.

M  +6    -0    checks/ruleofthree.cpp
M  +1    -1    tests/rule-of-three/main.cpp
M  +7    -2    tests/rule-of-three/main.h

http://commits.kde.org/clazy/7947f1ab62801f978557e6ea2f193f07276042a9