Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Either I'm missing your point entirely, or you are using <code>clang_equalCursors</code> the wrong way: when both cursors are equals, <code>clang_equalCursors</code> returns a non-zero value. Which means I think you're testing cursors inequalities instead of equalities.</p> <p>Now, let me try to explain why certain cursors apparently behave differently than others. Each cursor has only one source location. However, there might be several cursors at the same source location. Think for example about the following line:</p> <pre><code>CXIndex index = clang_createIndex(0, 0); // ^ </code></pre> <p>There should be at least two cursors at the marked position above:</p> <ol> <li>VarDecl: <code>index</code></li> <li>DeclRefExpr: <code>index = clang_createIndex(0,0)</code></li> </ol> <p>When you convert the source location back to a cursor, <code>clang_getCursor</code> gives you the most specific one (the variable declaration in this case). I suspect this is what happens to you in this case: <code>getCursor(loc)</code> only gives you back the cursor that you are visiting if it is the most specific at its location.</p> <p>Try printing the physical source location of each cursor (using for example <a href="http://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html#ga79f6544534ab73c78a8494c4c0bc2840" rel="nofollow">clang_getCursorExtent</a> and <a href="http://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gadee4bea0fa34550663e869f48550eb1f" rel="nofollow">clang_getExpansionLocation</a>) to understand what happens.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload