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
This commit is contained in:
Ted Kremenek 2011-03-18 02:06:53 +00:00
Родитель 7d2f9d54bd
Коммит 965fe844ce
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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);
}