diff options
author | Steve Naroff <snaroff@apple.com> | 2009-09-24 20:03:06 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-09-24 20:03:06 +0000 |
commit | a7753c492e37a4b58fc786ad7adc5807186642ee (patch) | |
tree | e10460182a5db570cd6f3d69983b8f8ca787955e /clang/tools/c-index-test/c-index-test.c | |
parent | 8ccfcb51ee020c4ca0e76838a2ef57cb5bb77914 (diff) | |
download | bcm5719-llvm-a7753c492e37a4b58fc786ad7adc5807186642ee.tar.gz bcm5719-llvm-a7753c492e37a4b58fc786ad7adc5807186642ee.zip |
Add test for C-based indexing API, using FileCheck utility.
llvm-svn: 82706
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 9e94058e0d3..f1f9372a187 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -4,33 +4,37 @@ #include <stdio.h> #include <string.h> +extern char *basename(const char *); + static void PrintCursor(CXCursor Cursor) { if (clang_isInvalid(Cursor.kind)) printf("Invalid Cursor => %s\n", clang_getCursorKindSpelling(Cursor.kind)); else - printf("%s => %s ", clang_getCursorKindSpelling(Cursor.kind), - clang_getCursorSpelling(Cursor)); + printf("%s=%s", clang_getCursorKindSpelling(Cursor.kind), + clang_getCursorSpelling(Cursor)); } static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { + printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Cursor)), + clang_getCursorLine(Cursor), + clang_getCursorColumn(Cursor)); PrintCursor(Cursor); - printf("(Context: %s", clang_getDeclSpelling(Dcl)); - printf(" Source: %s (%d:%d))\n", clang_getCursorSource(Cursor), - clang_getCursorLine(Cursor), - clang_getCursorColumn(Cursor)); + printf(" [Context=%s]\n", clang_getDeclSpelling(Dcl)); } } static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, CXClientData Filter) { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { + printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Cursor)), + clang_getCursorLine(Cursor), + clang_getCursorColumn(Cursor)); PrintCursor(Cursor); - printf("(Context: %s", clang_getTranslationUnitSpelling(Unit)); - printf(" Source: %s (%d:%d))\n", clang_getCursorSource(Cursor), - clang_getCursorLine(Cursor), - clang_getCursorColumn(Cursor)); + printf(" [Context=%s]\n", basename(clang_getTranslationUnitSpelling(Unit))); + + clang_loadDeclaration(Cursor.decl, DeclVisitor, 0); if (Cursor.kind == CXCursor_FunctionDefn) { const char *startBuf, *endBuf; @@ -54,16 +58,15 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor), curLine, curColumn); if (Ref.kind != CXCursor_FunctionDecl) { + printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Ref)), + curLine, curColumn); PrintCursor(Ref); - printf("(Context: %s", clang_getDeclSpelling(Ref.decl)); - printf(" Source: %s (%d:%d))\n", clang_getCursorSource(Ref), - curLine, curColumn); + printf(" [Context:%s]\n", clang_getDeclSpelling(Ref.decl)); } startBuf++; } } } - clang_loadDeclaration(Cursor.decl, DeclVisitor, 0); } } |