Getting Started

Hi, is there any documentation on getting started using the Clang libraries in a project? A few months back, I had it working with the code below, but it has since broken. I looked a bit and it's non-obvious how to do this correctly (I simply want to run an ASTConsumer over a source file).

-- Joe Ranieri

TextDiagnosticBuffer diagClient;
Diagnostic diags(&diagClient);
LangOptions opts;
opts.ObjC1 = true;
opts.ObjC2 = true;
opts.ObjCNonFragileABI = true;
opts.Blocks = true;

FileManager fm;
SourceManager sm;
HeaderSearch headers(fm);
InitHeaderSearch init(headers);
init.AddDefaultSystemIncludePaths(opts);
init.Realize();

const FileEntry* file = fm.getFile(argv[1]);
sm.createMainFileID(file, SourceLocation());

OwningPtr<TargetInfo> target(TargetInfo::CreateTargetInfo(LLVM_HOSTTRIPLE));
Preprocessor pp(diags, opts, *target, sm, headers);
ASTContext context(pp.getLangOptions(),
           pp.getSourceManager(),
           pp.getTargetInfo(),
           pp.getIdentifierTable(),
           pp.getSelectorTable(),
           pp.getBuiltinInfo());

TestConsumer consumer;
ParseAST(pp, &consumer, context, false);