[PATCH] D97152: [clang-tidy] Simplify special member functions check

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 27 04:15:38 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb67287088664: [clang-tidy] Simplify special member functions check (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97152/new/

https://reviews.llvm.org/D97152

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -32,7 +32,9 @@
   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,
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -40,18 +40,13 @@
 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);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97152.326895.patch
Type: text/x-patch
Size: 2365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210227/f83680bc/attachment.bin>


More information about the cfe-commits mailing list