[cfe-dev] Example code for parse & lex libraries

Philippe Hausler phausler at gmail.com
Wed May 12 21:17:12 PDT 2010


I have been testing my google-fu with no avail for decent (and up to date) example code for the usage for Clang's libraries (particularly parse and lex). The wpa example provided doesn't seem to work right with my build and I need to figure out if it is a build issue with my libraries or a platform implementation issue. The clang-c examples in Index.h also don't seem to work right. 

For example:

CXIndex Idx = clang_createIndex(1, 1);
CXTranslationUnit TU = clang_createTranslationUnit(Idx, "IndexTest.pch");

TU is returning as NULL even when IndexTest.pch exists in the same directory as the binary product. Which is befuddling to say the least. I was expecting TU to actually be set to something sensible and of course this poses problems down the road when clang_visitChildren is called. However the Idx is being created correctly from what I can tell. 

My build of the libraries for llvm and clang both seemed to work flawlessly so I am not sure what is going on. Couple of caveats: I am building both llvm and clang for arm-apple-darwin10, its being built in Xcode 3.2, and builds with zero warnings and a few scattered warnings (most of which are reasonable).

Any light shed on this would be appreciated.

Philippe Hausler



More information about the cfe-dev mailing list