// Finalize the action.
EndSourceFileAction();
- // Release the consumer and the AST, in that order since the consumer may
- // perform actions in its destructor which require the context.
+ // Sema references the ast consumer, so reset sema first.
//
// FIXME: There is more per-file stuff we could just drop here?
- if (CI.getFrontendOpts().DisableFree) {
- BuryPointer(CI.takeASTConsumer());
+ bool DisableFree = CI.getFrontendOpts().DisableFree;
+ if (DisableFree) {
if (!isCurrentFileAST()) {
CI.resetAndLeakSema();
CI.resetAndLeakASTContext();
}
+ BuryPointer(CI.takeASTConsumer());
} else {
if (!isCurrentFileAST()) {
CI.setSema(0);
// FrontendAction.
CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
- if (isCurrentFileAST()) {
+ if (DisableFree && isCurrentFileAST()) {
CI.resetAndLeakSema();
CI.resetAndLeakASTContext();
CI.resetAndLeakPreprocessor();