From: Ted Kremenek Date: Fri, 18 Mar 2011 03:44:21 +0000 (+0000) Subject: Construct 'Sema' object on the stack, so that crash recovery can recovery it's associ... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=934a57194c9ee3db2dc38fc0222296621c4d2c8a;p=clang Construct 'Sema' object on the stack, so that crash recovery can recovery it's associated resources without walking over dead stack space. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127864 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp index 97e5b60f52..bca0fa7ba5 100644 --- a/lib/Parse/ParseAST.cpp +++ b/lib/Parse/ParseAST.cpp @@ -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 @@ -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 S(new Sema(PP, Ctx, *Consumer, + CompleteTranslationUnit, + CompletionConsumer)); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar SemaCleanupInCrash(llvm::CrashRecoveryContextCleanup:: - create(&S)); + create(S.get())); - ParseAST(S, PrintStats); + ParseAST(*S.get(), PrintStats); } void clang::ParseAST(Sema &S, bool PrintStats) {