Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 1 | |
| 2 | #include "clang-c/Index.h" |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 3 | #include <stdio.h> |
| 4 | |
| 5 | static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) { |
Steve Naroff | 2d4d629 | 2009-08-31 14:26:51 +0000 | [diff] [blame] | 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 | } |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 13 | } |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 14 | |
| 15 | /* |
| 16 | * First sign of life:-) |
| 17 | */ |
| 18 | int main(int argc, char **argv) { |
| 19 | CXIndex Idx = clang_createIndex(); |
| 20 | CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]); |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 21 | clang_loadTranslationUnit(TU, PrintDecls); |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 22 | return 1; |
| 23 | } |