c-index-test.c revision 2d4d629d8a0de5112c7ae9d05c03ddbf6dcd956a
1 2#include "clang-c/Index.h" 3#include <stdio.h> 4 5static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) { 6 if (clang_isDeclaration(Cursor.kind)) { 7 printf("%s => %s", clang_getKindSpelling(Cursor.kind), 8 clang_getDeclSpelling(Cursor.decl)); 9 printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor), 10 clang_getCursorLine(Cursor), 11 clang_getCursorColumn(Cursor)); 12 } 13} 14 15/* 16 * First sign of life:-) 17 */ 18int main(int argc, char **argv) { 19 CXIndex Idx = clang_createIndex(); 20 CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]); 21 clang_loadTranslationUnit(TU, PrintDecls); 22 return 1; 23} 24