[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.
Roy Jacobson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 12 11:30:42 PST 2023
royjacobson created this revision.
royjacobson added reviewers: carlosgalvezp, njames93, aaron.ballman.
Herald added subscribers: kbarton, xazax.hun, nemanjai.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.
A somewhat common code-pattern is to default a destructor in the source file and not in the header.
For example, this is the way to use smart pointers with forward-declared classes:
c++
struct Impl;
struct A {
~A(); // Can't be defaulted in the header.
private:
std::unique_ptr<Impl> impl;
};
To be able to use this check with this pattern, I modified the behavior with `AllowSoleDefaultDtor`
to not trigger on destructors if they aren't defined yet.
Since a declared destructor should still be defined somewhere in the program, this doesn't
won't miss bad classes, just diagnose on less translation units.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143851
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143851.496777.patch
Type: text/x-patch
Size: 6994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230212/95bbe06c/attachment.bin>
More information about the cfe-commits
mailing list