Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xb8g2pw0 opened this issue Sep 5, 2023 · 1 comment · Fixed by #67939
Closed

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

xb8g2pw0 opened this issue Sep 5, 2023 · 1 comment · Fixed by #67939
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@xb8g2pw0
Copy link

xb8g2pw0 commented Sep 5, 2023

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.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Sep 5, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 5, 2023

@llvm/issue-subscribers-clang-frontend

5chmidti added a commit to 5chmidti/llvm-project that referenced this issue Oct 3, 2023
The BoundNodesTreeBuilder used in the BaseSpecMatcher was the original
and was reset to its original state if a match occurred.
The matcher now uses the local copy in the inner matcher.

Fixes llvm#65421
AaronBallman pushed a commit that referenced this issue Oct 16, 2023
The BoundNodesTreeBuilder used in the BaseSpecMatcher was the original
and was reset to its original state if a match occurred.
The matcher now uses the local copy in the inner matcher.

Fixes #65421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants