diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-20 00:34:58 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-20 00:34:58 +0000 |
commit | aa0cd85838f2a024e589ea4e8c2094130065af21 (patch) | |
tree | b4e013c1268210fa0769c263d702c637395b59ae /tools/c-index-test/c-index-test.c | |
parent | ed36b2a80878c29603bdc89a7969253fb6446174 (diff) |
Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158771 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 | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 497c9ee6af..4c9723da01 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -218,7 +218,9 @@ static void PrintCursor(CXCursor Cursor) { CXPlatformAvailability PlatformAvailability[2]; int NumPlatformAvailability; int I; - + CXString Comment; + const char *CommentCString; + ks = clang_getCursorKindSpelling(Cursor.kind); string = want_display_name? clang_getCursorDisplayName(Cursor) : clang_getCursorSpelling(Cursor); @@ -398,6 +400,22 @@ static void PrintCursor(CXCursor Cursor) { if (!clang_equalRanges(CursorExtent, RefNameRange)) PrintRange(RefNameRange, "RefName"); } + + Comment = clang_Cursor_getRawCommentText(Cursor); + CommentCString = clang_getCString(Comment); + if (CommentCString != NULL && CommentCString[0] != '\0') { + printf(" Comment=["); + for ( ; *CommentCString; ++CommentCString) { + if (*CommentCString != '\n') + putchar(*CommentCString); + else + printf("\\n"); + } + printf("]"); + + PrintRange(clang_Cursor_getCommentRange(Cursor), "CommentRange"); + } + clang_disposeString(Comment); } } |