From 614f96a7cf94805c2d336639300b62dc2f54e9e0 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 22 Mar 2011 01:15:17 +0000 Subject: [PATCH] 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 --- include/clang/Parse/Parser.h | 1 - lib/Parse/ParseAST.cpp | 14 ++++++++++---- lib/Parse/Parser.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index b9af05e58f..d07f605270 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -76,7 +76,6 @@ class Parser : public CodeCompletionHandler { friend class ColonProtectionRAIIObject; friend class InMessageExpressionRAIIObject; friend class ParenBraceBracketBalancer; - PrettyStackTraceParserEntry CrashInfo; Preprocessor &PP; diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp index bca0fa7ba5..21917b23ff 100644 --- a/lib/Parse/ParseAST.cpp +++ b/lib/Parse/ParseAST.cpp @@ -45,9 +45,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, CompletionConsumer)); // Recover resources if we crash before exiting this method. - llvm::CrashRecoveryContextCleanupRegistrar - SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup:: - create(S.get())); + llvm::CrashRecoveryContextCleanupRegistrar CleaupSema(S.get()); ParseAST(*S.get(), PrintStats); } @@ -61,7 +59,15 @@ void clang::ParseAST(Sema &S, bool PrintStats) { ASTConsumer *Consumer = &S.getASTConsumer(); - Parser P(S.getPreprocessor(), S); + llvm::OwningPtr ParseOP(new Parser(S.getPreprocessor(), S)); + Parser &P = *ParseOP.get(); + + PrettyStackTraceParserEntry CrashInfo(P); + + // Recover resources if we crash before exiting this method. + llvm::CrashRecoveryContextCleanupRegistrar + CleaupParser(ParseOP.get()); + S.getPreprocessor().EnterMainSourceFile(); P.Initialize(); S.Initialize(); diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 3946fc7208..60ca1d49e7 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -22,7 +22,7 @@ using namespace clang; Parser::Parser(Preprocessor &pp, Sema &actions) - : CrashInfo(*this), PP(pp), Actions(actions), Diags(PP.getDiagnostics()), + : PP(pp), Actions(actions), Diags(PP.getDiagnostics()), GreaterThanIsOperator(true), ColonIsSacred(false), InMessageExpression(false), TemplateParameterDepth(0) { Tok.setKind(tok::eof);