<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/136435>136435</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang_equalCursors not work as expect
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
neko-para
</td>
</tr>
</table>
<pre>
I'm using my own nodejs binding of libclang to parse my source to generate a simplified ast.
```typescript
// dfs logic, using cursors as a stack
function parseAnnotate(tu: CTranslationUnit) {
const root = tu.cursor
const cursors: CCursor[] = [root]
tu.cursor.visitChildren((cursor, parent) => {
while (cursors.length > 0 && !cursors[0].equal(parent)) {
cursors.shift()
}
if (cursors.length === 0) {
console.warn('jump out root', cursor, parent)
}
cursors.unshift(cursor)
console.log(' '.repeat(cursors.length - 2), cursor.spelling, cursor.kindStr)
return CXChildVisitResult.Recurse
})
}
```
The code above works quite well, but when parsing the code below, the cursors that should be equal become different.
```
_Const_lvalue_cond_oper ClassTemplatePartialSpecialization
_Ty1 TemplateTypeParameter
_Ty2 TemplateTypeParameter
RequiresExpr
> Here should be a TemplateRef with parent of RequiresExpr, but my program crashed
```

https://github.com/microsoft/STL/blob/5762e6bcaf7f5f8b5dba0a9aabf0acbd0e335e80/stl/inc/type_traits#L1288
**After dumping the CXCursor data, it shows that the parent.data[0] is non-zero, while cursors[0].data[0] (previously stored one) is zero, causing clang_equalCursors return false.**
I think there should be some problem either on my binding code or the way I use libclang, but I'm not sure.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VUtv2zoT_TX0ZmBBpl72wovEqfEF6OJDmnvRnTGiRhYbilT5iOv--gvq4SZ9CQQSk2eGZ4ZnZtA5edZEe1bcs-JhhcF3xu41vZj1gBZXtWmu-0fGqx6Ck_oM_RXMRYM2DX1xUEvdxF3TgpK1UKjP4A0MaB1FqDPBCopbZ9Jk0RMgONkPSraSGkDnE5b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