From 4d96d9f0e758fb9244749f99d4b0a3ab1e3e0592 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 19 Mar 2011 01:00:36 +0000 Subject: [PATCH] Recover memory from RecordLayoutBuilders during crashes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127931 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/RecordLayoutBuilder.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 016b405fa0..a8ba8e24e7 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -19,7 +19,7 @@ #include "llvm/Support/Format.h" #include "llvm/ADT/SmallSet.h" #include "llvm/Support/MathExtras.h" -#include +#include "llvm/Support/CrashRecoveryContext.h" using namespace clang; @@ -1708,6 +1708,11 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const { case CXXABI_Microsoft: Builder.reset(new MSRecordLayoutBuilder(*this, &EmptySubobjects)); } + // Recover resources if we crash before exiting this method. + llvm::CrashRecoveryContextCleanupRegistrar + RecordBuilderCleanup(llvm::CrashRecoveryContextCleanup:: + create(Builder.get())); + Builder->Layout(RD); // FIXME: This is not always correct. See the part about bitfields at -- 2.40.0