Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -42,6 +42,8 @@ anyOf(refersToTemplate(templateName().bind("used")), refersToDeclaration(functionDecl().bind("used"))))))), this); + Finder->addMatcher(loc(templateSpecializationType( + hasAnyTemplateArgument(templateArgument().bind("used")))), this); } void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { @@ -91,6 +93,18 @@ return; } + if (const auto *Used = Result.Nodes.getNodeAs("used")) { + // FIXME: Support non-type template parameters. + if (Used->getKind() == TemplateArgument::Template) { + if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl()) + removeFromFoundDecls(TD); + } else if (Used->getKind() == TemplateArgument::Type) { + if (auto *RD = Used->getAsType()->getAsCXXRecordDecl()) + removeFromFoundDecls(RD); + } + return; + } + if (const auto *Used = Result.Nodes.getNodeAs("used")) { removeFromFoundDecls(Used->getAsTemplateDecl()); return; Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp @@ -21,6 +21,16 @@ class G; class H; +template class K {}; +template