Reinstate r133513 (reverted in r133700) with an additional fix for a
[oota-llvm.git] / include / llvm / Support / CrashRecoveryContext.h
index 759d2f8c71827013a2eaabaabd151399a1e4204b..4c0a5e26f00f0e80fe7d043238eead8f79457cb8 100644 (file)
@@ -101,11 +101,10 @@ class CrashRecoveryContextCleanup {
 protected:
   CrashRecoveryContext *context;
   CrashRecoveryContextCleanup(CrashRecoveryContext *context)
-    : context(context) {}
+    : context(context), cleanupFired(false) {}
 public:
   bool cleanupFired;
   
-  CrashRecoveryContextCleanup() : cleanupFired(false) {}
   virtual ~CrashRecoveryContextCleanup();
   virtual void recoverResources() = 0;
 
@@ -187,8 +186,13 @@ public:
   }
 
   ~CrashRecoveryContextCleanupRegistrar() {
+    unregister();
+  }
+  
+  void unregister() {
     if (cleanup && !cleanup->cleanupFired)
-        cleanup->getContext()->unregisterCleanup(cleanup);
+      cleanup->getContext()->unregisterCleanup(cleanup);
+    cleanup = 0;
   }
 };
 }