[cfe-dev] loading and traversing an AST
josef maxim pohl
josef.m.pohl at gmail.com
Thu Oct 27 08:46:48 PDT 2011
Here is yet another new person question.
I have, after a long while, cobbled together an example that I thought would
simply traverse create an AST and then traverse it printing out function and
variable names. Sadly, I am getting the following error:
clang::Preprocessor::EnterMainSourceFile(): Assertion `NumEnteredSourceFiles
== 0 && "Cannot reenter the main file!"' failed.
0. <eof> parser at end of file
Which makes me believe that my AST is not being created properly
I create the ASTUnit after an example sent by Guoping using:
And then have a ASTConsumer instance that implements HandleTranslationUnit
and two methods, VisitFunctionDecl and VisitVarDecl. But I suspect the
error is coming before the call to any of these.
Perhaps I have not set up the call to ParseAST properly?
clang::ParseAST(TU.getPreprocessor(), consumer, TU.getASTContext());
TU is a wrapper around ASTUnit as in the wpa example.
Any thoughts I what I might try to remedy this situation?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev