@@ -222,6 +222,19 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, TypedefNameDecl>
222222extern const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl>
223223 typeAliasDecl;
224224
225+ // / \brief Matches shadow declarations introduced into a scope by a
226+ // / (resolved) using declaration.
227+ // /
228+ // / Given
229+ // / \code
230+ // / namespace n { int f; }
231+ // / namespace declToImport { using n::f; }
232+ // / \endcode
233+ // / usingShadowDecl()
234+ // / matches \code f \endcode
235+ extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingShadowDecl>
236+ usingShadowDecl;
237+
225238// / Matches type alias template declarations.
226239// /
227240// / typeAliasTemplateDecl() matches
@@ -3740,7 +3753,7 @@ extern const internal::VariadicOperatorMatcherFunc<1, 1> unless;
37403753// / Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
37413754// / Matcher<TagType>, Matcher<TemplateSpecializationType>,
37423755// / Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
3743- // / Matcher<UnresolvedUsingType>
3756+ // / Matcher<UnresolvedUsingType>, Matcher<UsingType>
37443757inline internal::PolymorphicMatcher<
37453758 internal::HasDeclarationMatcher,
37463759 void (internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>
@@ -4375,7 +4388,13 @@ AST_POLYMORPHIC_MATCHER_P(throughUsingDecl,
43754388 AST_POLYMORPHIC_SUPPORTED_TYPES (DeclRefExpr,
43764389 UsingType),
43774390 internal::Matcher<UsingShadowDecl>, Inner) {
4378- const NamedDecl *FoundDecl = Node.getFoundDecl ();
4391+ const NamedDecl *FoundDecl;
4392+ if constexpr (std::is_same_v<NodeType, UsingType>) {
4393+ FoundDecl = Node.getDecl ();
4394+ } else {
4395+ static_assert (std::is_same_v<NodeType, DeclRefExpr>);
4396+ FoundDecl = Node.getFoundDecl ();
4397+ }
43794398 if (const UsingShadowDecl *UsingDecl = dyn_cast<UsingShadowDecl>(FoundDecl))
43804399 return Inner.matches (*UsingDecl, Finder, Builder);
43814400 return false ;
@@ -7004,37 +7023,6 @@ AST_POLYMORPHIC_MATCHER_P2(
70047023 InnerMatcher.matches (Args[Index], Finder, Builder);
70057024}
70067025
7007- // / Matches C or C++ elaborated `TypeLoc`s.
7008- // /
7009- // / Given
7010- // / \code
7011- // / struct s {};
7012- // / struct s ss;
7013- // / \endcode
7014- // / elaboratedTypeLoc()
7015- // / matches the `TypeLoc` of the variable declaration of `ss`.
7016- extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, ElaboratedTypeLoc>
7017- elaboratedTypeLoc;
7018-
7019- // / Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
7020- // / `InnerMatcher`.
7021- // /
7022- // / Given
7023- // / \code
7024- // / template <typename T>
7025- // / class C {};
7026- // / class C<int> c;
7027- // /
7028- // / class D {};
7029- // / class D d;
7030- // / \endcode
7031- // / elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
7032- // / matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
7033- AST_MATCHER_P (ElaboratedTypeLoc, hasNamedTypeLoc, internal::Matcher<TypeLoc>,
7034- InnerMatcher) {
7035- return InnerMatcher.matches (Node.getNamedTypeLoc (), Finder, Builder);
7036- }
7037-
70387026// / Matches type \c bool.
70397027// /
70407028// / Given
@@ -7301,7 +7289,7 @@ extern const AstTypeMatcher<DecltypeType> decltypeType;
73017289AST_TYPE_TRAVERSE_MATCHER (hasDeducedType, getDeducedType,
73027290 AST_POLYMORPHIC_SUPPORTED_TYPES (AutoType));
73037291
7304- // / Matches \c DecltypeType or \c UsingType nodes to find the underlying type.
7292+ // / Matches \c QualType nodes to find the underlying type.
73057293// /
73067294// / Given
73077295// / \code
@@ -7311,10 +7299,13 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType,
73117299// / decltypeType(hasUnderlyingType(isInteger()))
73127300// / matches the type of "a"
73137301// /
7314- // / Usable as: Matcher<DecltypeType>, Matcher<UsingType>
7315- AST_TYPE_TRAVERSE_MATCHER (hasUnderlyingType, getUnderlyingType,
7316- AST_POLYMORPHIC_SUPPORTED_TYPES (DecltypeType,
7317- UsingType));
7302+ // / Usable as: Matcher<QualType>
7303+ AST_MATCHER_P (Type, hasUnderlyingType, internal::Matcher<QualType>, Inner) {
7304+ QualType QT = Node.getLocallyUnqualifiedSingleStepDesugaredType ();
7305+ if (QT == QualType (&Node, 0 ))
7306+ return false ;
7307+ return Inner.matches (QT, Finder, Builder);
7308+ }
73187309
73197310// / Matches \c FunctionType nodes.
73207311// /
@@ -7593,27 +7584,7 @@ extern const AstTypeMatcher<RecordType> recordType;
75937584// / and \c c.
75947585extern const AstTypeMatcher<TagType> tagType;
75957586
7596- // / Matches types specified with an elaborated type keyword or with a
7597- // / qualified name.
7598- // /
7599- // / Given
7600- // / \code
7601- // / namespace N {
7602- // / namespace M {
7603- // / class D {};
7604- // / }
7605- // / }
7606- // / class C {};
7607- // /
7608- // / class C c;
7609- // / N::M::D d;
7610- // / \endcode
7611- // /
7612- // / \c elaboratedType() matches the type of the variable declarations of both
7613- // / \c c and \c d.
7614- extern const AstTypeMatcher<ElaboratedType> elaboratedType;
7615-
7616- // / Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7587+ // / Matches Types whose qualifier, a NestedNameSpecifier,
76177588// / matches \c InnerMatcher if the qualifier exists.
76187589// /
76197590// / Given
@@ -7628,34 +7599,14 @@ extern const AstTypeMatcher<ElaboratedType> elaboratedType;
76287599// /
76297600// / \c elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
76307601// / matches the type of the variable declaration of \c d.
7631- AST_MATCHER_P (ElaboratedType , hasQualifier,
7632- internal::Matcher<NestedNameSpecifier>, InnerMatcher) {
7633- if (const NestedNameSpecifier * Qualifier = Node.getQualifier ())
7634- return InnerMatcher.matches (* Qualifier, Finder, Builder);
7602+ AST_MATCHER_P (Type , hasQualifier, internal::Matcher<NestedNameSpecifier> ,
7603+ InnerMatcher) {
7604+ if (NestedNameSpecifier Qualifier = Node.getPrefix ())
7605+ return InnerMatcher.matches (Qualifier, Finder, Builder);
76357606
76367607 return false ;
76377608}
76387609
7639- // / Matches ElaboratedTypes whose named type matches \c InnerMatcher.
7640- // /
7641- // / Given
7642- // / \code
7643- // / namespace N {
7644- // / namespace M {
7645- // / class D {};
7646- // / }
7647- // / }
7648- // / N::M::D d;
7649- // / \endcode
7650- // /
7651- // / \c elaboratedType(namesType(recordType(
7652- // / hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
7653- // / declaration of \c d.
7654- AST_MATCHER_P (ElaboratedType, namesType, internal::Matcher<QualType>,
7655- InnerMatcher) {
7656- return InnerMatcher.matches (Node.getNamedType (), Finder, Builder);
7657- }
7658-
76597610// / Matches types specified through a using declaration.
76607611// /
76617612// / Given
0 commit comments