@@ -25,6 +25,13 @@ AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl,
2525 return false ;
2626}
2727
28+ AST_MATCHER_P (Type, asTagDecl, clang::ast_matchers::internal::Matcher<TagDecl>,
29+ DeclMatcher) {
30+ if (const TagDecl *ND = Node.getAsTagDecl ())
31+ return DeclMatcher.matches (*ND, Finder, Builder);
32+ return false ;
33+ }
34+
2835} // namespace
2936
3037// A function that helps to tell whether a TargetDecl in a UsingDecl will be
@@ -61,7 +68,8 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
6168 Finder->addMatcher (userDefinedLiteral ().bind (" used" ), this );
6269 Finder->addMatcher (
6370 loc (elaboratedType (unless (hasQualifier (nestedNameSpecifier ())),
64- hasUnqualifiedDesugaredType (type ().bind (" usedType" )))),
71+ hasUnqualifiedDesugaredType (
72+ type (asTagDecl (tagDecl ().bind (" used" )))))),
6573 this );
6674 // Cases where we can identify the UsingShadowDecl directly, rather than
6775 // just its target.
@@ -139,12 +147,6 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
139147 return ;
140148 }
141149
142- if (const auto *T = Result.Nodes .getNodeAs <Type>(" usedType" )) {
143- if (const auto *ND = T->getAsTagDecl ())
144- RemoveNamedDecl (ND);
145- return ;
146- }
147-
148150 if (const auto *UsedShadow =
149151 Result.Nodes .getNodeAs <UsingShadowDecl>(" usedShadow" )) {
150152 removeFromFoundDecls (UsedShadow->getTargetDecl ());
0 commit comments