Construct 'Sema' object on the stack, so that crash recovery can recovery it's associated resources without walking over dead stack space.

llvm-svn: 127864
This commit is contained in:
Ted Kremenek 2011-03-18 03:44:21 +00:00
parent 2d60add66c
commit c93cf2e912
1 changed files with 7 additions and 3 deletions

View File

@ -21,6 +21,7 @@
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/Stmt.h"
#include "clang/Parse/Parser.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include <cstdio>
@ -38,14 +39,17 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
ASTContext &Ctx, bool PrintStats,
bool CompleteTranslationUnit,
CodeCompleteConsumer *CompletionConsumer) {
Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit, CompletionConsumer);
llvm::OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer,
CompleteTranslationUnit,
CompletionConsumer));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar
SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup::
create<Sema>(&S));
create<Sema>(S.get()));
ParseAST(S, PrintStats);
ParseAST(*S.get(), PrintStats);
}
void clang::ParseAST(Sema &S, bool PrintStats) {