================
@@ -224,10 +224,19 @@ void SpecialMemberFunctionsCheck::checkForMissingMembers(
                    SpecialMemberFunctionKind::CopyAssignment);
   }
 
+  const bool CopyImplicitlyDeleted =
+      HasImplicitDeletedMember(SpecialMemberFunctionKind::CopyConstructor) &&
+      HasImplicitDeletedMember(SpecialMemberFunctionKind::CopyAssignment);
+  const bool MoveMissing =
+      !HasMember(SpecialMemberFunctionKind::MoveConstructor) &&
+      !HasMember(SpecialMemberFunctionKind::MoveAssignment);
----------------
zeyi2 wrote:

> Why we use HasImplicitDeletedMember for copy but not for move as well?

[`RequireMembers()`](https://github.com/llvm/llvm-project/blob/5c715d56884364a3b05acb4d3e6b52a911f14667/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp#L188)
 already handles the symmetric case where the requested pair is implicitly 
deleted. That is why using `HasImplicitDeletedMember()` for move here would not 
add anything new.

The motivating case for the PR is a bit different: 

```cpp
struct A : boost::noncopyable {
  ~A() { std::cout << "dtor\n"; }
};
```

The copy operations are implicit and deleted, but the move operations are not 
implicit-deleted members. They are not declared at all (Please see 
https://eel.is/c++draft/class.copy.ctor#8 and 
https://eel.is/c++draft/class.copy.assign#4).

Therefore `HasImplicitDeletedMember()` for the move constructor and move 
assignment operator would still be false, which is why the existing 
`RequireMembers()` handling did not suppress this diagnostic.

https://github.com/llvm/llvm-project/pull/207586
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to