<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65421>65421</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bindings enclosed within hasAnyBase() don't work
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xb8g2pw0
</td>
</tr>
</table>
<pre>
Bindings enclosed within a `hasAnyBase()` expression don't work. Fortunately, the workaround `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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVEtv4zYQ_jXUZRCBIk0lOujgR13sYXso9h6Q0kRiS5EqH3bcQ397QcnoZr3eoEBOawiiyXlw5vtGnwxBDxaxJWJHxKGQKY7Ot6_qaWDzmRbK9Zd2p22v7RAAbWdcwB7OOo7aggRS01GGrb3sZEDCnghrSE0BX2ePIWhnoXeWsMcIZ-f_LOHofExWRjQXwvYQR1wM0rtk-5xNhwN6fcL-6N30NWHvMFxTfBkRdAgJQc4zSh9AW1Aujjm8M9IOD38l9JccJm2frZOM3Yg-gEraRJABJOyzJ8wmDdqWhB4I3a7vX_UJ7VJZkNNsEGbvBi8nwrdv3UhNr8-y7YwMAXZAHnfk8UD47u3xgfAtzEkZ3X3vcpMot3et9659gu719XfsnO8P2BnCnr4hYJThy2XO_-64_SanlSS2I4xlaFlTKm379VD9d3h97jYqU8AAb4CG6MBjTN7eDficmwHCeHWD4D7vxV6GSMR-yfcsQ3xWaXiuym6eCd9ywrc5DKyLmFfCmHcuEsYg1x1gRI9vod6_C7X45Z_vf6utWlEv7_awS3GZiHWw_h8tt5P8UT7u3bq-Z-_61GF4f0I_wkN1hwf1YxLeBf6nI_8TyAlS0Ha4isaprOqSlpusYOdRdyN8AoVG4wnhs_tbGyNXpSmLvuV9wxtZYFvVDW-EEKIqxvbppX6kCje0qVklVdPwjqqN4n0t6MuLwEK3jDJOGyoYrxinJatq0WBDNyg5io6SDcVJalMac5pK54diEcW2FhtWFUYqNGFRdcYsnlfFzPMkDoVvc8yDSkMgG2p0iOFrlqijwR9L_q3af6PvRfKmHWOcl1FkR8KOg45jUmWXP4FjvuS6PMze_YFdJOy4lBYIOy6l_xsAAP__E5nypw">