Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 614f96a

Browse files
committed
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
1 parent 55c0258 commit 614f96a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

include/clang/Parse/Parser.h

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class Parser : public CodeCompletionHandler {
7676
friend class ColonProtectionRAIIObject;
7777
friend class InMessageExpressionRAIIObject;
7878
friend class ParenBraceBracketBalancer;
79-
PrettyStackTraceParserEntry CrashInfo;
8079

8180
Preprocessor &PP;
8281

lib/Parse/ParseAST.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
4545
CompletionConsumer));
4646

4747
// Recover resources if we crash before exiting this method.
48-
llvm::CrashRecoveryContextCleanupRegistrar
49-
SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup::
50-
create<Sema>(S.get()));
48+
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get());
5149

5250
ParseAST(*S.get(), PrintStats);
5351
}
@@ -61,7 +59,15 @@ void clang::ParseAST(Sema &S, bool PrintStats) {
6159

6260
ASTConsumer *Consumer = &S.getASTConsumer();
6361

64-
Parser P(S.getPreprocessor(), S);
62+
llvm::OwningPtr<Parser> ParseOP(new Parser(S.getPreprocessor(), S));
63+
Parser &P = *ParseOP.get();
64+
65+
PrettyStackTraceParserEntry CrashInfo(P);
66+
67+
// Recover resources if we crash before exiting this method.
68+
llvm::CrashRecoveryContextCleanupRegistrar<Parser>
69+
CleaupParser(ParseOP.get());
70+
6571
S.getPreprocessor().EnterMainSourceFile();
6672
P.Initialize();
6773
S.Initialize();

lib/Parse/Parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using namespace clang;
2323

2424
Parser::Parser(Preprocessor &pp, Sema &actions)
25-
: CrashInfo(*this), PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
25+
: PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
2626
GreaterThanIsOperator(true), ColonIsSacred(false),
2727
InMessageExpression(false), TemplateParameterDepth(0) {
2828
Tok.setKind(tok::eof);

0 commit comments

Comments
 (0)