[PATCH] D39217: [libclang, bindings]: add spelling location
Johann Klähn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 25 01:54:57 PDT 2017
jklaehn added inline comments.
================
Comment at: test/Index/c-index-getCursor-test.m:167
// CHECK: [57:1 - 57:10] FunctionDecl=f:57:6 (Definition)
-// CHECK: [58:4 - 58:8] VarDecl=my_var:58:8 (Definition)
+// CHECK: [58:4 - 58:8] VarDecl=my_var:2:1 (Definition)
// CHECK: [58:8 - 58:15] macro expansion=CONCAT:55:9
----------------
frutiger wrote:
> jklaehn wrote:
> > This does not seem to refer to a valid location? (line 2 only contains a comment)
> I don't really understand this output. What is `-test-file-scan` supposed to show?
Given this argument `c-index-test` will use `clang_getCursor` to iterate through all cursors in the file (by calling it on each character location and checking if it is equal to the previous cursor).
The numbers in brackets (e.g. `[58:4 - 58:8]`) indicate the locations for which `clang_getCursor` returned the same cursor. `VarDecl=my_var:2:1 (Definition)` is the output of `PrintCursor`. In this case `:2:1` is IIUC produced by
```
Referenced = clang_getCursorReferenced(Cursor);
if (!clang_equalCursors(Referenced, clang_getNullCursor())) {
if (clang_getCursorKind(Referenced) == CXCursor_OverloadedDeclRef) {
// [...]
} else {
CXSourceLocation Loc = clang_getCursorLocation(Referenced);
clang_getSpellingLocation(Loc, 0, &line, &column, 0);
printf(":%d:%d", line, column);
}
// [...]
}
```
So it is affected by the change to `clang_getSpellingLocation`. I'm not sure what the referenced cursor is in this case. Maybe it would be helpful to also print its kind.
https://reviews.llvm.org/D39217
More information about the cfe-commits
mailing list