Recover memory from RecordLayoutBuilders during crashes.

llvm-svn: 127931
This commit is contained in:
Ted Kremenek 2011-03-19 01:00:36 +00:00
parent ddc06d0bd0
commit f75d089679
1 changed files with 6 additions and 1 deletions

View File

@ -19,7 +19,7 @@
#include "llvm/Support/Format.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/MathExtras.h"
#include <map>
#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<RecordLayoutBuilder>(Builder.get()));
Builder->Layout(RD);
// FIXME: This is not always correct. See the part about bitfields at