objective c - Parse AST from an ObjC header using libClang -
objective c - Parse AST from an ObjC header using libClang -
i'm using libclang lint objective-c codes. stuck in parsing objc header file (.m fine) , can ast standalone ? here's test codes, trying @interfaces , @protocols.
void clangtest(void) { cxindex index = clang_createindex(0, 1); const char *args[] = { // should have 1 ? }; int numargs = sizeof(args) / sizeof(*args); cxtranslationunit tu = clang_parsetranslationunit(index, "/path/to/anobjcclass.h", args, numargs, null, 0, cxtranslationunit_none); clang_visitchildrenwithblock(clang_gettranslationunitcursor(tu), ^(cxcursor cursor, cxcursor parent){ // never reach here if (clang_getcursorkind(cursor) == cxcursor_objcinterfacedecl || clang_getcursorkind(cursor) == cxcursor_objcprotocoldecl) { // neither here, hoped } homecoming cxchildvisit_continue; }); }
objective-c libclang
Comments
Post a Comment