You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
+30-14Lines changed: 30 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,9 @@ namespace class_implicit_ctor {
4
4
template <typename T>
5
5
classCRTP {};
6
6
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
7
-
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private
7
+
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private and declaring the derived class as friend
8
8
// CHECK-FIXES: CRTP() = default;
9
+
// CHECK-FIXES: friend T;
9
10
10
11
classA : CRTP<A> {};
11
12
} // namespace class_implicit_ctor
@@ -28,8 +29,9 @@ class CRTP {
28
29
public:
29
30
CRTP() = default;
30
31
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the CRTP to be constructed as a regular template class [bugprone-crtp-constructor-accessibility]
31
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
32
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the CRTP to be constructed as a regular template class [bugprone-crtp-constructor-accessibility]
44
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
46
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the CRTP to be constructed as a regular template class [bugprone-crtp-constructor-accessibility]
57
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
60
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the CRTP to be constructed as a regular template class [bugprone-crtp-constructor-accessibility]
61
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
64
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows the CRTP to be inherited from as a regular template class [bugprone-crtp-constructor-accessibility]
74
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
80
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows the CRTP to be inherited from as a regular template class [bugprone-crtp-constructor-accessibility]
78
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
84
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows the CRTP to be inherited from as a regular template class [bugprone-crtp-constructor-accessibility]
82
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
88
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
93
-
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private
103
+
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the CRTP to be constructed as a regular template class [bugprone-crtp-constructor-accessibility]
104
-
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private
115
+
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
115
-
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private
127
+
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
121
-
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private
134
+
// CHECK-MESSAGES: :[[@LINE-2]]:8: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
168
-
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private
182
+
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private and declaring the derived class as friend
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-crtp-constructor-accessibility]
185
-
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private
200
+
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private and declaring the derived class as friend
0 commit comments