Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType()))), unless(hasSourceExpression(hasType(sugaredNullptrType())))); return castExpr(anyOf(ImplicitCastToNull, Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,20 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +class TemplateClass { + public: + explicit TemplateClass(int a, T default_value = 0) {} + + void h(T *default_value = 0) {} + + void f(int* p = 0) {} +// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr +// CHECK-FIXES: void f(int* p = nullptr) {} +}; + +void IgnoreSubstTemplateType() { + TemplateClass a(1); +}