[all-commits] [llvm/llvm-project] aa56e6: [clang-tidy] Tweak 'rule of 3/5' checks to allow d...
Roy Jacobson via All-commits
all-commits at lists.llvm.org
Sun Feb 26 03:58:20 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: aa56e66bf7520512fd1209cbb7d099604a5f6277
https://github.com/llvm/llvm-project/commit/aa56e66bf7520512fd1209cbb7d099604a5f6277
Author: Roy Jacobson <roi.jacobson1 at gmail.com>
Date: 2023-02-26 (Sun, 26 Feb 2023)
Changed paths:
M clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
M clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/special-member-functions.rst
M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-cxx-03.cpp
M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-relaxed.cpp
M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions.cpp
Log Message:
-----------
[clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.
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
won't miss bad classes, just diagnose on less translation units.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D143851
More information about the All-commits
mailing list