]> granicus.if.org Git - clang/commitdiff
Use CrashRecoveryContextCleanup objects to release resources associated with Sema...
authorTed Kremenek <kremenek@apple.com>
Fri, 18 Mar 2011 02:06:53 +0000 (02:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 18 Mar 2011 02:06:53 +0000 (02:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127850 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseAST.cpp

index edb1675b99e5aa9334b24c6db4f0cff1bf68fc53..97e5b60f5276dbc3ce1415f3b4ad0fa0c3e04de4 100644 (file)
@@ -21,6 +21,7 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Parse/Parser.h"
+#include "llvm/Support/CrashRecoveryContext.h"
 #include <cstdio>
 
 using namespace clang;
@@ -38,6 +39,12 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
                      bool CompleteTranslationUnit,
                      CodeCompleteConsumer *CompletionConsumer) {
   Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit, CompletionConsumer);
+
+  // Recover resources if we crash before exiting this method.
+  llvm::CrashRecoveryContextCleanupRegistrar
+    SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup::
+                        create<Sema>(&S));
+  
   ParseAST(S, PrintStats);
 }