Construct 'Sema' object on the stack, so that crash recovery can recovery it's associated resources without walking over dead stack space.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127864 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp
index 97e5b60..bca0fa7 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/ADT/OwningPtr.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include <cstdio>
@@ -38,14 +39,17 @@
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) {