Skip to content

Commit b672870

Browse files
committed
[clang-tidy] Simplify special member functions check
Differential Revision: https://reviews.llvm.org/D97152
1 parent a5feefa commit b672870

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,13 @@ void SpecialMemberFunctionsCheck::storeOptions(
4040
void SpecialMemberFunctionsCheck::registerMatchers(MatchFinder *Finder) {
4141
Finder->addMatcher(
4242
cxxRecordDecl(
43-
eachOf(
44-
has(cxxDestructorDecl(unless(isImplicit())).bind("dtor")),
45-
has(cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))
46-
.bind("copy-ctor")),
47-
has(cxxMethodDecl(isCopyAssignmentOperator(),
48-
unless(isImplicit()))
49-
.bind("copy-assign")),
50-
has(cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))
51-
.bind("move-ctor")),
52-
has(cxxMethodDecl(isMoveAssignmentOperator(),
53-
unless(isImplicit()))
54-
.bind("move-assign"))))
43+
eachOf(has(cxxDestructorDecl().bind("dtor")),
44+
has(cxxConstructorDecl(isCopyConstructor()).bind("copy-ctor")),
45+
has(cxxMethodDecl(isCopyAssignmentOperator())
46+
.bind("copy-assign")),
47+
has(cxxConstructorDecl(isMoveConstructor()).bind("move-ctor")),
48+
has(cxxMethodDecl(isMoveAssignmentOperator())
49+
.bind("move-assign"))))
5550
.bind("class-def"),
5651
this);
5752
}

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ class SpecialMemberFunctionsCheck : public ClangTidyCheck {
3232
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
3333
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3434
void onEndOfTranslationUnit() override;
35-
35+
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
36+
return TK_IgnoreUnlessSpelledInSource;
37+
}
3638
enum class SpecialMemberFunctionKind : uint8_t {
3739
Destructor,
3840
DefaultDestructor,

0 commit comments

Comments
 (0)