[cfe-commits] r127864 - /cfe/trunk/lib/Parse/ParseAST.cpp

Ted Kremenek kremenek at apple.com
Thu Mar 17 20:44:21 PDT 2011


Author: kremenek
Date: Thu Mar 17 22:44:21 2011
New Revision: 127864

URL: http://llvm.org/viewvc/llvm-project?rev=127864&view=rev
Log:
Construct 'Sema' object on the stack, so that crash recovery can recovery it's associated resources without walking over dead stack space.

Modified:
    cfe/trunk/lib/Parse/ParseAST.cpp

Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=127864&r1=127863&r2=127864&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Thu Mar 17 22:44:21 2011
@@ -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) {





More information about the cfe-commits mailing list