diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 016b405fa013..a8ba8e24e756 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/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