[cfe-commits] r128056 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseAST.cpp lib/Parse/Parser.cpp

Ted Kremenek kremenek at apple.com
Mon Mar 21 18:15:17 PDT 2011


Author: kremenek
Date: Mon Mar 21 20:15:17 2011
New Revision: 128056

URL: http://llvm.org/viewvc/llvm-project?rev=128056&view=rev
Log:
Migrate 'PrettySTackTraceParserEntry' object out of Parser, and have it constructed within ParseAST.  This avoids double crashes
during crash recovery.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseAST.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=128056&r1=128055&r2=128056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Mar 21 20:15:17 2011
@@ -76,7 +76,6 @@
   friend class ColonProtectionRAIIObject;
   friend class InMessageExpressionRAIIObject;
   friend class ParenBraceBracketBalancer;
-  PrettyStackTraceParserEntry CrashInfo;
 
   Preprocessor &PP;
 

Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=128056&r1=128055&r2=128056&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Mon Mar 21 20:15:17 2011
@@ -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();

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=128056&r1=128055&r2=128056&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Mar 21 20:15:17 2011
@@ -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);





More information about the cfe-commits mailing list