@@ -25,6 +25,13 @@ AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl,
25
25
return false ;
26
26
}
27
27
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
+
28
35
} // namespace
29
36
30
37
// A function that helps to tell whether a TargetDecl in a UsingDecl will be
@@ -61,7 +68,8 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
61
68
Finder->addMatcher (userDefinedLiteral ().bind (" used" ), this );
62
69
Finder->addMatcher (
63
70
loc (elaboratedType (unless (hasQualifier (nestedNameSpecifier ())),
64
- hasUnqualifiedDesugaredType (type ().bind (" usedType" )))),
71
+ hasUnqualifiedDesugaredType (
72
+ type (asTagDecl (tagDecl ().bind (" used" )))))),
65
73
this );
66
74
// Cases where we can identify the UsingShadowDecl directly, rather than
67
75
// just its target.
@@ -139,12 +147,6 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
139
147
return ;
140
148
}
141
149
142
- if (const auto *T = Result.Nodes .getNodeAs <Type>(" usedType" )) {
143
- if (const auto *ND = T->getAsTagDecl ())
144
- RemoveNamedDecl (ND);
145
- return ;
146
- }
147
-
148
150
if (const auto *UsedShadow =
149
151
Result.Nodes .getNodeAs <UsingShadowDecl>(" usedShadow" )) {
150
152
removeFromFoundDecls (UsedShadow->getTargetDecl ());
0 commit comments