-
Notifications
You must be signed in to change notification settings - Fork 0
/
futhest.c
38 lines (26 loc) · 947 Bytes
/
futhest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <assert.h>
#include <stdio.h>
#include "clang-c/Index.h"
enum CXChildVisitResult
visitor(CXCursor cursor, CXCursor parent, CXClientData clientData) {
CXFile file;
unsigned int line;
unsigned int column;
unsigned int offset;
CXSourceLocation loc = clang_getCursorLocation(cursor);
clang_getFileLocation(loc, &file, &line, &column, &offset);
CXString filename = clang_getFileName(file);
printf("%s [%d:%d, %d]\n", clang_getCString(filename), line, column, offset);
clang_disposeString(filename);
return CXChildVisit_Continue;
}
int main (void) {
CXIndex Idx = clang_createIndex(0, 0);
CXTranslationUnit TU = clang_parseTranslationUnit(Idx,
"src/header.h", NULL, 0, NULL, 0, 0);
assert(TU != NULL);
CXCursor cursor = clang_getTranslationUnitCursor(TU);
clang_visitChildren(cursor, visitor, NULL);
clang_disposeTranslationUnit(TU);
printf("END");
}