Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp @@ -241,6 +241,7 @@ if (SpecialFunctionDecl->isDeleted() || SpecialFunctionDecl->isExplicitlyDefaulted() || SpecialFunctionDecl->isLateTemplateParsed() || + SpecialFunctionDecl->isTemplateInstantiation() || !SpecialFunctionDecl->isUserProvided() || !SpecialFunctionDecl->hasBody()) return; Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp @@ -124,6 +124,26 @@ // CHECK-FIXES: ~Temp() = default; }; +// Class template out of line with explicit instantiation. +template +class TempODef { +public: + TempODef(); + ~TempODef(); +}; + +template +TempODef::TempODef() {} +// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default' +// CHECK-FIXES: TempODef::TempODef() = default; +template +TempODef::~TempODef() {} +// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default' +// CHECK-FIXES: TempODef::~TempODef() = default; + +template class TempODef; +template class TempODef; + // Non user-provided constructor/destructor. struct Imp { int Int;