]> granicus.if.org Git - clang/commitdiff
Call llvm::remove_fatal_error_handler before deallocating objects
authorDan Gohman <gohman@apple.com>
Wed, 18 Aug 2010 21:23:17 +0000 (21:23 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 18 Aug 2010 21:23:17 +0000 (21:23 +0000)
which are used by the error handling functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111427 91177308-0d34-0410-b5e6-96231b3b80d8

tools/driver/cc1_main.cpp
tools/driver/cc1as_main.cpp

index 2eb5fd381da0b0ee3c77ecfc92e8ce9bf7ee6b89..bfdcefbb24e36a7bf9f69867295e10f55144ef51 100644 (file)
@@ -163,6 +163,11 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
   // results now.  This happens in -disable-free mode.
   llvm::TimerGroup::printAll(llvm::errs());
 
+  // Our error handler depends on the Diagnostics object, which we're
+  // potentially about to delete. Uninstall the handler now so that any
+  // later errors use the default handling behavior instead.
+  llvm::remove_fatal_error_handler();
+
   // When running with -disable-free, don't do any destruction or shutdown.
   if (Clang->getFrontendOpts().DisableFree) {
     if (Clang->getFrontendOpts().ShowStats)
index 077e118d246e581c884526a1c3951c0ac5fdfef4..4620b605fb052bc45513a34ca4bdd7cee5445f86 100644 (file)
@@ -327,8 +327,8 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd,
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
-  install_fatal_error_handler(LLVMErrorHandler,
-                                    static_cast<void*>(&Diags));
+  ScopedFatalErrorHandler FatalErrorHandler
+    (LLVMErrorHandler, static_cast<void*>(&Diags));
 
   // Parse the arguments.
   AssemblerInvocation Asm;