aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseAST.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-18 02:06:53 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-18 02:06:53 +0000
commit965fe844ceb6b840f79c7987deaed48ee30d070d (patch)
tree1533d4345fc15fefc5cea93025beb734033a2b6a /lib/Parse/ParseAST.cpp
parent7d2f9d54bd99f4b4689cb386b51d1b066c883a9e (diff)
Use CrashRecoveryContextCleanup objects to release resources associated with Sema during a crash while parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127850 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseAST.cpp')
-rw-r--r--lib/Parse/ParseAST.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp
index edb1675b99..97e5b60f52 100644
--- a/lib/Parse/ParseAST.cpp
+++ b/lib/Parse/ParseAST.cpp
@@ -21,6 +21,7 @@
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/Stmt.h"
#include "clang/Parse/Parser.h"
+#include "llvm/Support/CrashRecoveryContext.h"
#include <cstdio>
using namespace clang;
@@ -38,6 +39,12 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
bool CompleteTranslationUnit,
CodeCompleteConsumer *CompletionConsumer) {
Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit, CompletionConsumer);
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar
+ SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup::
+ create<Sema>(&S));
+
ParseAST(S, PrintStats);
}