Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp @@ -246,8 +246,12 @@ // Check whether we have multiple hand-written constructors and bomb out, as // it is hard to reconcile their sets of member initializers. const auto *ClassDecl = cast(Field->getParent()); - if (llvm::count_if(ClassDecl->ctors(), [](const CXXConstructorDecl *Ctor) { - return !Ctor->isCopyOrMoveConstructor(); + if (llvm::count_if(ClassDecl->decls(), [](const Decl *D) { + if (const auto *Ctor = dyn_cast(D)) + return !Ctor->isCopyOrMoveConstructor(); + if (const auto *FTD = dyn_cast(D)) + return isa(FTD->getTemplatedDecl()); + return false; }) > 1) return; Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp +++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp @@ -60,6 +60,20 @@ int i; }; +struct TwoConstructorsTpl { + TwoConstructorsTpl() : i{7} {} + template TwoConstructorsTpl(T, int) : i(8) {} + int i; +}; + +struct PositiveConstructorTpl { + template PositiveConstructorTpl(T, int) : i(8) {} + // CHECK-FIXES: PositiveConstructorTpl(T, int) {} + int i; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i' + // CHECK-FIXES: int i{8}; +}; + struct PositiveNotDefaultOOLInt { PositiveNotDefaultOOLInt(int); int i; @@ -237,6 +251,14 @@ NegativeTemplate nti; NegativeTemplate ntd; +template struct PositiveTemplate { + PositiveTemplate() : i(9) {} + // CHECK-FIXES: PositiveTemplate() {} + int i; + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i' + // CHECK-FIXES: int i{9}; +}; + struct NegativeDefaultMember { NegativeDefaultMember() {} int i = 2;