Use auto instead of the long type name. NFC.
[oota-llvm.git] / lib / Support / Unix / Signals.inc
index e7696c2f7eec622ec133f0391dc5c8167ea893e3..bfe2a3a380edcb7efe4c38e5b88d41894105a9fb 100644 (file)
@@ -139,6 +139,11 @@ static void UnregisterHandlers() {
 /// NB: This must be an async signal safe function. It cannot allocate or free
 /// memory, even in debug builds.
 static void RemoveFilesToRemove() {
+  // Avoid constructing ManagedStatic in the signal handler.
+  // If FilesToRemove is not constructed, there are no files to remove.
+  if (!FilesToRemove.isConstructed())
+    return;
+
   // We avoid iterators in case of debug iterators that allocate or release
   // memory.
   std::vector<std::string>& FilesToRemoveRef = *FilesToRemove;
@@ -200,10 +205,11 @@ static RETSIGTYPE SignalHandler(int Sig) {
   }
 
   // Otherwise if it is a fault (like SEGV) run any handler.
-  std::vector<std::pair<void (*)(void *), void *>>& CallBacksToRunRef =
-      *CallBacksToRun;
-  for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i)
-    CallBacksToRunRef[i].first(CallBacksToRunRef[i].second);
+  if (CallBacksToRun.isConstructed()) {
+    auto &CallBacksToRunRef = *CallBacksToRun;
+    for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i)
+      CallBacksToRunRef[i].first(CallBacksToRunRef[i].second);
+  }
 
 #ifdef __s390__
   // On S/390, certain signals are delivered with PSW Address pointing to