diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-30 20:58:35 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-30 20:58:35 +0000 |
commit | ba1da14e79c1ecd49306e5175b69baa1e7ed4293 (patch) | |
tree | fadf008f39453edc380c16ba305c0326579ce99a /tools/c-index-test/c-index-test.c | |
parent | 6c4c36c4ed1007143f5b8655eb68b313a7e12e76 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153775 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 5dd9254631..e774e78086 100644 --- a/tools/c-index-test/c-index-test.c +++ b/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: "); |