<div dir="ltr">Hello,<div><br></div><div style>I'm using libclang to search through CXCursors to match variable references to their definitions.</div><div style><br></div><div style>To do this, I'm storing a list of the definitions, and whenever I come across a reference, I call 'clang_getCursorDefinition' and compare for equality. For my equality check, I just see if the CXSourceRange's of the two cursors are equal.</div>
<div style><br></div><div style>This works well unless I have a definition like:</div><div style><br></div><div style>    int n, sum = 0;<br></div><div style><br></div><div style>In this case, when I encounter the definition CXCursor through my tree search (through clang_visitChildren), the range covers 'sum = 0'. But when I call 'clang_getCursorDefinition' on a reference, the range for the returned CXCursor covers 'int n, sum = 0'.</div>
<div style><br></div><div style>Is there a way to get the more precise range from a cursor referencing the variable? Or is there a simpler way to compare for equality between a definition cursor and a reference cursor for the same variable?</div>
<div style><br></div><div style>Thanks, Peter</div></div>