1// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -config="{CheckOptions: {cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: true}}" --
2
3class DefinesEverything {
4 DefinesEverything(const DefinesEverything &);
5 DefinesEverything(DefinesEverything &&);
6 DefinesEverything &operator=(const DefinesEverything &);
7 DefinesEverything &operator=(DefinesEverything &&);
8 ~DefinesEverything();
9};
10
11class DefinesNothing {
12};
13
14class DeletedCopyCtorAndOperator {
15 ~DeletedCopyCtorAndOperator() = default;
16 DeletedCopyCtorAndOperator(const DeletedCopyCtorAndOperator &) = delete;
17 DeletedCopyCtorAndOperator &operator=(const DeletedCopyCtorAndOperator &) = delete;
18};
19
20// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'DefaultedCopyCtorAndOperator' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
21class DefaultedCopyCtorAndOperator {
22 ~DefaultedCopyCtorAndOperator() = default;
23 DefaultedCopyCtorAndOperator(const DefaultedCopyCtorAndOperator &) = default;
24 DefaultedCopyCtorAndOperator &operator=(const DefaultedCopyCtorAndOperator &) = default;
25};
26
27// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'DefinedCopyCtorAndOperator' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
28class DefinedCopyCtorAndOperator {
29 ~DefinedCopyCtorAndOperator() = default;
30 DefinedCopyCtorAndOperator(const DefinedCopyCtorAndOperator &);
31 DefinedCopyCtorAndOperator &operator=(const DefinedCopyCtorAndOperator &);
32};
33
34// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'MissingCopyCtor' defines a default destructor and a copy assignment operator but does not define a copy constructor, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
35class MissingCopyCtor {
36 ~MissingCopyCtor() = default;
37 MissingCopyCtor &operator=(const MissingCopyCtor &) = delete;
38};
39
40// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'MissingCopyOperator' defines a default destructor and a copy constructor but does not define a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
41class MissingCopyOperator {
42 ~MissingCopyOperator() = default;
43 MissingCopyOperator(const MissingCopyOperator &) = delete;
44};
45
46// CHECK-MESSAGES: [[@LINE+1]]:7: warning: class 'MissingAll' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
47class MissingAll {
48 ~MissingAll() = default;
49};
50

source code of clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/special-member-functions-allow-missing-move-when-copy-is-deleted.cpp