Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -40,6 +40,7 @@ Token Tok; int ParenLevel = 0; + int AngleBracketLevel = 0; bool FoundTypedef = false; while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) { @@ -54,10 +55,16 @@ case tok::r_paren: ParenLevel--; break; + case tok::less: // '<', start template + AngleBracketLevel++; + break; + case tok::greater: // '>', end template + AngleBracketLevel--; + break; case tok::comma: - if (ParenLevel == 0) { - // If there is comma and we are not between open parenthesis then it is - // two or more declarations in this chain. + if (ParenLevel == 0 && AngleBracketLevel == 0) { + // If there is comma and we are not between open parenthesis or between + // open angle brackets then it is two or more declarations in this chain. return false; } break; @@ -88,8 +95,7 @@ if (StartLoc.isMacroID() && IgnoreMacros) return; - auto Diag = - diag(StartLoc, "use 'using' instead of 'typedef'"); + auto Diag = diag(StartLoc, "use 'using' instead of 'typedef'"); // do not fix if there is macro or array if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID()) Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp +++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp @@ -182,4 +182,11 @@ class E : public C<E> { void f() override { super::f(); } }; + +template <typename T1, typename T2> +class TwoArgTemplate { + typedef TwoArgTemplate<T1, T2> self; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' + // CHECK-FIXES: using self = TwoArgTemplate<T1, T2>; +}; }