]> granicus.if.org Git - clang/commitdiff
Produce an actual error before attempting to attach notes to it when bailing out
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Dec 2012 21:56:27 +0000 (21:56 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Dec 2012 21:56:27 +0000 (21:56 +0000)
due to FORCE_CLANG_DIAGNOSTICS_CRASH=1. Also add a test for that env var.

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

include/clang/Basic/DiagnosticDriverKinds.td
test/Driver/crash-report.c
tools/driver/driver.cpp

index a8b21173dbbed10fc1db4ad3316663731aac98d3..5fec06dc8876ad9784b7b23cb26b8369c10d33e6 100644 (file)
@@ -67,6 +67,8 @@ def err_drv_command_failed : Error<
   "%0 command failed with exit code %1 (use -v to see invocation)">;
 def err_drv_command_signalled : Error<
   "%0 command failed due to signal (use -v to see invocation)">;
+def err_drv_force_crash : Error<
+  "failing because environment variable '%0' is set">;
 def err_drv_invalid_mfloat_abi : Error<
   "invalid float ABI '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<
index bfcd5732b33dd4577eaedf1965700229a1704670..975e9a8a714f82bfd38263905ec37dc754623d5e 100644 (file)
@@ -9,6 +9,8 @@
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 // REQUIRES: crash-recovery
 
+// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH=1 %clang -fsyntax-only -x c /dev/null 2>&1 | FileCheck %s
+
 #pragma clang __debug parser_crash
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.c
index 353d06fb14e4cb5c9ee64926651d346d9bce1589..de2b899bfaa8ff5697b22715eae2aef3b0d49874 100644 (file)
@@ -16,6 +16,7 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
 #include "clang/Driver/Options.h"
@@ -470,8 +471,10 @@ int main(int argc_, const char **argv_) {
     Res = TheDriver.ExecuteCompilation(*C, FailingCommand);
 
   // Force a crash to test the diagnostics.
-  if(::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
-     Res = -1;
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) {
+    Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH";
+    Res = -1;
+  }
 
   // If result status is < 0, then the driver command signalled an error.
   // If result status is 70, then the driver command reported a fatal error.