summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-30 20:58:35 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-30 20:58:35 +0000
commit191a6a86ad74f10b27250fb62483326f4b22c394 (patch)
tree83c79d8bf66e4ba41cda03fc54e1377cf96c0a6a /clang/tools/c-index-test/c-index-test.c
parentc15f55e267745a2374bbb636f789e462a8185a0e (diff)
downloadbcm5719-llvm-191a6a86ad74f10b27250fb62483326f4b22c394.tar.gz
bcm5719-llvm-191a6a86ad74f10b27250fb62483326f4b22c394.zip
[libclang] Introduce clang_Cursor_getSpellingNameRange().
It retrieves a source range for a piece that forms the cursors spelling name. Most of the times there is only one range for the complete spelling but for objc methods and objc message expressions, there are multiple pieces for each selector identifier. Part of rdar://11113120 llvm-svn: 153775
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 5dd92546313..e774e78086c 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -171,7 +171,8 @@ static void PrintRange(CXSourceRange R, const char *str) {
if (!begin_file || !end_file)
return;
- printf(" %s=", str);
+ if (str)
+ printf(" %s=", str);
PrintExtent(stdout, begin_line, begin_column, end_line, end_column);
}
@@ -1449,8 +1450,19 @@ static int inspect_cursor_at(int argc, const char **argv) {
PrintCursorExtent(Cursor);
Spelling = clang_getCursorSpelling(Cursor);
cspell = clang_getCString(Spelling);
- if (cspell && strlen(cspell) != 0)
- printf(" Spelling=%s", cspell);
+ if (cspell && strlen(cspell) != 0) {
+ unsigned pieceIndex;
+ CXSourceRange range, extent;
+ extent = clang_getCursorExtent(Cursor);
+ printf(" Spelling=%s (", cspell);
+ for (pieceIndex = 0; ; ++pieceIndex) {
+ range = clang_Cursor_getSpellingNameRange(Cursor, pieceIndex, 0);
+ if (clang_Range_isNull(range))
+ break;
+ PrintRange(range, 0);
+ }
+ printf(")");
+ }
clang_disposeString(Spelling);
if (completionString != NULL) {
printf("\nCompletion string: ");
OpenPOWER on IntegriCloud