]> granicus.if.org Git - clang/commitdiff
Recover memory from RecordLayoutBuilders during crashes.
authorTed Kremenek <kremenek@apple.com>
Sat, 19 Mar 2011 01:00:36 +0000 (01:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 19 Mar 2011 01:00:36 +0000 (01:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127931 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp

index 016b405fa013981be18d581b035a77d1e751877e..a8ba8e24e756ea05fb3087b8953b61f1ad26342b 100644 (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