#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Timer.h"
+#include "llvm/Support/CrashRecoveryContext.h"
#include <cstdlib>
#include <cstdio>
#include <sys/stat.h>
unsigned NumRemappedFiles,
bool CaptureDiagnostics) {
llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true));
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar
+ ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
+ create<ASTUnit>(AST.get()));
+
ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
AST->Invocation.reset(CI);
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar
+ ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
+ create<ASTUnit>(AST.get()));
+
return AST->LoadFromCompilerInvocation(PrecompilePreamble)? 0 : AST.take();
}
AST->NumStoredDiagnosticsInPreamble = StoredDiagnostics.size();
AST->StoredDiagnostics.swap(StoredDiagnostics);
AST->Invocation.reset(CI.take());
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar
+ ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
+ create<ASTUnit>(AST.get()));
+
return AST->LoadFromCompilerInvocation(PrecompilePreamble) ? 0 : AST.take();
}