blob: 1ef8e924bc3923925f7b00b0867f1b228eef57c2 [file] [log] [blame]
Steve Naroff50398192009-08-28 15:28:48 +00001
2#include "clang-c/Index.h"
Steve Naroff89922f82009-08-31 00:59:03 +00003#include <stdio.h>
4
5static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) {
Steve Naroff2d4d6292009-08-31 14:26:51 +00006 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 Naroff89922f82009-08-31 00:59:03 +000013}
Steve Naroff50398192009-08-28 15:28:48 +000014
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]);
Steve Naroff89922f82009-08-31 00:59:03 +000021 clang_loadTranslationUnit(TU, PrintDecls);
Steve Naroff50398192009-08-28 15:28:48 +000022 return 1;
23}