loading and traversing an AST

Hi all,
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:

~/llvm/tools/clang/lib/Lex/Preprocessor.cpp:386: void clang::Preprocessor::EnterMainSourceFile(): Assertion `NumEnteredSourceFiles == 0 && “Cannot reenter the main file!”’ failed.
Stack dump:
0. parser at end of file

Which makes me believe that my AST is not being created properly (obviously).

I create the ASTUnit after an example sent by Guoping using:

llvm::OwningPtr CUnit(

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,