ΒΆinline internal::PolymorphicMatcher<
    clang::ast_matchers::internal::
        HasDeclarationMatcher,
    void(internal::HasDeclarationSupportedTypes),
    internal::Matcher<Decl>>
hasDeclaration(
    const internal::Matcher<Decl>& InnerMatcher)

Description

Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: - for type nodes, the declaration of the underlying type - for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor - for CXXNewExpr, the declaration of the operator new - for ObjCIvarExpr, the declaration of the ivar For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher: In this matcher, the decl will match the CXXRecordDecl of class X. Usable as: Matcher <AddrLabelExpr >, Matcher <CallExpr >, Matcher <CXXConstructExpr >, Matcher <CXXNewExpr >, Matcher <DeclRefExpr >, Matcher <EnumType >, Matcher <InjectedClassNameType >, Matcher <LabelStmt >, Matcher <MemberExpr >, Matcher <QualType >, Matcher <RecordType >, Matcher <TagType >, Matcher <TemplateSpecializationType >, Matcher <TemplateTypeParmType >, Matcher <TypedefType >, Matcher <UnresolvedUsingType >

Declared at: clang/include/clang/ASTMatchers/ASTMatchers.h:3574

Parameters

const internal::Matcher<Decl>& InnerMatcher