[cfe-dev] AST Parser failure
Eli Friedman
eli.friedman at gmail.com
Thu Aug 9 15:26:07 PDT 2012
On Thu, Aug 9, 2012 at 9:29 AM, Socrates Katsoulacos
<socrates.katsoulacos11 at imperial.ac.uk> wrote:
> Dear Sir/Madam,
>
> I have the following code inside a class.
>
> //visit AST
> static CXChildVisitResult TranslationUnitVisitor(CXCursor, CXCursor,
> CXClientData data)
> {
> return CXChildVisit_Recurse; // visit complete AST recursivly
> }
>
>
> void VisitTranslationUnitWithPCH()
> {
> //create function pointer
> CXChildVisitResult (*pTranslationUnitVisitor)(CXCursor, CXCursor,
> CXClientData) = TranslationUnitVisitor;
> //excludeDeclsFromPCH = 1, displayDiagnostics=1
> CXIndex cx_idx = clang_createIndex(0, 1);
>
> //IndexTest.pch was produced with the following command:
> //"clang -x c test.h -emit-ast -o test.pch"
> //system("/home/socrates/llvm/Debug+Asserts/bin/clang -x c test.h -emit-ast
> -o test.pch");
> CXTranslationUnit TU = clang_createTranslationUnit(cx_idx, "test.pch");
>
> // This will load all the symbols from 'test.pch'
> clang_visitChildren(clang_getTranslationUnitCursor(TU),
> pTranslationUnitVisitor, 0);
> clang_disposeTranslationUnit(TU);
>
> // This will load all the symbols from 'test.c', excluding symbols
> // from 'test.pch'.
> char *args[] = { "-Xclang", "test.pch" };
Err, did you mean { "-include", "test.pch" }? -Xclang doesn't make
any sense here.
-Eli
More information about the cfe-dev
mailing list