[cfe-commits] r127851 - /cfe/trunk/lib/Frontend/ASTUnit.cpp
Ted Kremenek
kremenek at apple.com
Thu Mar 17 19:06:56 PDT 2011
Author: kremenek
Date: Thu Mar 17 21:06:56 2011
New Revision: 127851
URL: http://llvm.org/viewvc/llvm-project?rev=127851&view=rev
Log:
Use CrashRecoveryContextCleanup objects to recover an ASTUnit if we crash in ASTUnit::LoadFromCommandLine() and ASTUnit::LoadFromCompilerInvocation().
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=127851&r1=127850&r2=127851&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Mar 17 21:06:56 2011
@@ -44,6 +44,7 @@
#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>
@@ -500,6 +501,12 @@
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;
@@ -1579,6 +1586,11 @@
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();
}
@@ -1704,6 +1716,12 @@
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();
}
More information about the cfe-commits
mailing list