mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
Use CrashRecoveryContextCleanup objects to release resources associated with Sema during a crash while parsing.
llvm-svn: 127850
This commit is contained in:
parent
c44d3cf581
commit
750028b6f4
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user