aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
blob: 3126b319efdad17c9a44484bb6cb346cfb9f1eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "clang-c/Index.h"
#include <stdio.h>

static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) {
 if (clang_isDeclaration(Cursor.kind))
   printf("%s => %s\n", clang_getKindSpelling(Cursor.kind),
                        clang_getDeclSpelling(Cursor.decl));
}

/*
 * First sign of life:-)
 */
int main(int argc, char **argv) {
  CXIndex Idx = clang_createIndex();
  CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]);
  clang_loadTranslationUnit(TU, PrintDecls);
  return 1;
}