]> granicus.if.org Git - clang/commitdiff
Construct 'Sema' object on the stack, so that crash recovery can recovery it's associ...
authorTed Kremenek <kremenek@apple.com>
Fri, 18 Mar 2011 03:44:21 +0000 (03:44 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 18 Mar 2011 03:44:21 +0000 (03:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127864 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseAST.cpp

index 97e5b60f5276dbc3ce1415f3b4ad0fa0c3e04de4..bca0fa7ba501f1475a3537be961bdb74a512f73f 100644 (file)
@@ -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 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
                      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) {