Migrate 'PrettySTackTraceParserEntry' object out of Parser, and have it constructed within ParseAST. This avoids double crashes
during crash recovery.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128056 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp
index bca0fa7..21917b2 100644
--- a/lib/Parse/ParseAST.cpp
+++ b/lib/Parse/ParseAST.cpp
@@ -45,9 +45,7 @@
CompletionConsumer));
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup::
- create<Sema>(S.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get());
ParseAST(*S.get(), PrintStats);
}
@@ -61,7 +59,15 @@
ASTConsumer *Consumer = &S.getASTConsumer();
- Parser P(S.getPreprocessor(), S);
+ llvm::OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S));
+ Parser &P = *ParseOP.get();
+
+ PrettyStackTraceParserEntry CrashInfo(P);
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<Parser>
+ CleaupParser(ParseOP.get());
+
S.getPreprocessor().EnterMainSourceFile();
P.Initialize();
S.Initialize();