Skip to content

Bindings enclosed within hasAnyBase() don't work #65421

@xb8g2pw0

Description

@xb8g2pw0

Bindings enclosed within a hasAnyBase() expression don't work. Fortunately, isDerivedFrom() does work. The issue appears in both clang-query and in matchers built as a Clang plugin.

Given the sample program:

class B {};
class D: public B {};

The matcher

m cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("B")).bind("b"))))

causes clang-query to return

Match #1:

C:\ast\clang_ast_bug_1.cpp:3:1: note: "root" binds here
class C: public B {};
^~~~~~~~~~~~~~~~~~~~
1 match.

But the query

m cxxRecordDecl(isDerivedFrom(cxxRecordDecl(hasName("B")).bind("b")))

produces:

Match #1:

C:\ast\clang_ast_bug_1.cpp:1:1: note: "b" binds here
class B {};
^~~~~~~~~~
C:\ast\clang_ast_bug_1.cpp:3:1: note: "root" binds here
class C: public B {};
^~~~~~~~~~~~~~~~~~~~
1 match.

I am using Clang v.16.0.4, which I believe Mozilla built.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions