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) { |
| 6 | if (clang_isDeclaration(Cursor.kind)) |
| 7 | printf("%s => %s\n", clang_getKindSpelling(Cursor.kind), |
| 8 | clang_getDeclSpelling(Cursor.decl)); |
| 9 | } |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * First sign of life:-) |
| 13 | */ |
| 14 | int main(int argc, char **argv) { |
| 15 | CXIndex Idx = clang_createIndex(); |
| 16 | CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]); |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame^] | 17 | clang_loadTranslationUnit(TU, PrintDecls); |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 18 | return 1; |
| 19 | } |