Accessing ASTContext after run() invocation

Hi all,

Suppose we have created a ClangTool in libtooling.
Is there a way to record ASTContexts (say, in the consumer), and access them after clangTool.run(…)?

For example:

std::vector<ASTContext*> contexts;
int main(int argc, char **argv) {

CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);

ClangTool Tool(OptionsParser.getCompilations(),

OptionsParser.getSourcePathList());

Tool.run(newFrontendActionFactory().get());

// I want to access contexts[i] here and possibly use the rewriter.
}

Any help is appreciated.

Pardis,

I believe this is not possible. The ClangTool::run method calls FrontendActionFactory::runInvocation which captures the FrontEndAction with a unique_ptr, thus freeing everything before it returns.

Can you detail further what you intend to do?