File tree 3 files changed +21
-6
lines changed 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -241,7 +241,9 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
241
241
this );
242
242
Finder->addMatcher (
243
243
cxxConstructorDecl (
244
- unless (hasParent (IsUnionLikeClass)), isDefinition (),
244
+ unless (
245
+ hasParent (decl (anyOf (IsUnionLikeClass, functionTemplateDecl ())))),
246
+ isDefinition (),
245
247
anyOf (
246
248
// Default constructor.
247
249
allOf (unless (hasAnyConstructorInitializer (isWritten ())),
@@ -257,8 +259,9 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
257
259
this );
258
260
// Copy-assignment operator.
259
261
Finder->addMatcher (
260
- cxxMethodDecl (unless (hasParent (IsUnionLikeClass)), isDefinition (),
261
- isCopyAssignmentOperator (),
262
+ cxxMethodDecl (unless (hasParent (
263
+ decl (anyOf (IsUnionLikeClass, functionTemplateDecl ())))),
264
+ isDefinition (), isCopyAssignmentOperator (),
262
265
// isCopyAssignmentOperator() allows the parameter to be
263
266
// passed by value, and in this case it cannot be
264
267
// defaulted.
Original file line number Diff line number Diff line change @@ -158,9 +158,9 @@ Changes in existing checks
158
158
The check now skips unions/union-like classes since in this case a default constructor
159
159
with empty body is not equivalent to the explicitly defaulted one, variadic constructors
160
160
since they cannot be explicitly defaulted. The check also skips copy assignment operators
161
- with nonstandard return types, private/protected default constructors for C++17 or earlier.
162
- The automatic fixit has been adjusted to avoid adding superfluous semicolon.
163
- The check is restricted to C++11 or later.
161
+ with nonstandard return types, template constructors, private/protected default constructors
162
+ for C++17 or earlier. The automatic fixit has been adjusted to avoid adding superfluous
163
+ semicolon. The check is restricted to C++11 or later.
164
164
165
165
- Change the default behavior of :doc: `readability-avoid-const-params-in-decls
166
166
<clang-tidy/checks/readability/avoid-const-params-in-decls>` to not
Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ struct VA {
58
58
VA (...) {}
59
59
};
60
60
61
+ // Skip template constructors.
62
+ struct TC {
63
+ template <unsigned U>
64
+ TC () {}
65
+
66
+ template <unsigned U>
67
+ TC (const TC &) {}
68
+
69
+ template <unsigned U>
70
+ TC& operator = (const TC &) { return *this ; }
71
+ };
72
+
61
73
// Initializer or arguments.
62
74
class IA {
63
75
public:
You can’t perform that action at this time.
0 commit comments