[clang-tidy] Simplify special member functions check

Differential Revision: https://reviews.llvm.org/D97152
This commit is contained in:
Stephen Kelly 2020-12-29 23:29:46 +00:00
parent a5feefa3c7
commit b672870886
2 changed files with 10 additions and 13 deletions

View File

@ -40,18 +40,13 @@ void SpecialMemberFunctionsCheck::storeOptions(
void SpecialMemberFunctionsCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
cxxRecordDecl(
eachOf(
has(cxxDestructorDecl(unless(isImplicit())).bind("dtor")),
has(cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))
.bind("copy-ctor")),
has(cxxMethodDecl(isCopyAssignmentOperator(),
unless(isImplicit()))
.bind("copy-assign")),
has(cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))
.bind("move-ctor")),
has(cxxMethodDecl(isMoveAssignmentOperator(),
unless(isImplicit()))
.bind("move-assign"))))
eachOf(has(cxxDestructorDecl().bind("dtor")),
has(cxxConstructorDecl(isCopyConstructor()).bind("copy-ctor")),
has(cxxMethodDecl(isCopyAssignmentOperator())
.bind("copy-assign")),
has(cxxConstructorDecl(isMoveConstructor()).bind("move-ctor")),
has(cxxMethodDecl(isMoveAssignmentOperator())
.bind("move-assign"))))
.bind("class-def"),
this);
}

View File

@ -32,7 +32,9 @@ public:
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void onEndOfTranslationUnit() override;
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
return TK_IgnoreUnlessSpelledInSource;
}
enum class SpecialMemberFunctionKind : uint8_t {
Destructor,
DefaultDestructor,