[Win32] Catch exceptions (eg. segfault) on waiting for invoked clang from the driver.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 29 Nov 2011 07:47:04 +0000 (07:47 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Tue, 29 Nov 2011 07:47:04 +0000 (07:47 +0000)
clang/lib/Driver/Driver.cpp: Don't pass through negative exit status, or parent would be confused.

llvm::sys::Program::Wait(): Suppose 0x8000XXXX and 0xC000XXXX as abnormal exit code and pass it as negative value.

Win32 Exception Handler: Exit with ExceptionCode on an unhandle exception.

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

lib/Support/Windows/Program.inc
lib/Support/Windows/Signals.inc

index 7e38168456794750b796dcc92eceb4650bd73593..80cb7cc232d3c51ccf12bc1bf2e8c0492e3d1120 100644 (file)
@@ -367,7 +367,17 @@ Program::Wait(const Path &path,
     return -2;
   }
 
-  return status & 0377;
+  if (!status)
+    return 0;
+
+  // Pass 10(Warning) and 11(Error) to the callee as negative value.
+  if ((status & 0xBFFF0000U) == 0x80000000U)
+    return (int)status;
+
+  if (status & 0xFF)
+    return status & 0x7FFFFFFF;
+
+  return 1;
 }
 
 bool
index 0d4b8a26b0232bcfa063830216bb0f8efdaf54c4..3a7e90b38e21cedb12826e655124ac3afdbfea1b 100644 (file)
@@ -446,7 +446,7 @@ static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
   }
 
   if (ExitOnUnhandledExceptions)
-    _exit(-3);
+    _exit(ep->ExceptionRecord->ExceptionCode);
 
   // Allow dialog box to pop up allowing choice to start debugger.
   if (OldFilter)