[PATCH] D73742: [Clang][Driver] After default -fintegrated-cc1, fix report_fatal_error no longer generates preprocessed source + reproducer.sh

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 13:42:58 PST 2020


aganea created this revision.
aganea added reviewers: arichardson, rnk, hans.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

As reported by @arichardson , this patch now makes `llvm::report_fatal_error()` to generate a preprocessed source + reproducer script again. Tested with/without the cmake flag CLANG_SPAWN_CC1. Tested in various configs, Debug/Release, with MSVC 19.24 or clang-cl 9.0.1, on Windows and Linux (with both gcc 9.2.1 and clang 9.0).

1. Added a CC1 flag, `-disable-pragma-debug-crash` to give a chance the crash diagnostic to generate a preprocessed output. Without this flag, the process started by `Driver::generateCompilationDiagnostics()` would fail execution in some cases, when `#pragma clang __debug` is used in the input.
2. Some CC1 M_group flags weren't cleared for diagnostics, which led to dangling files on the disk, after the crash diagnostics generated the preprocessed output. Such example is when `-MF file.d` was provided in the original cmd-line. The driver would cleanup the generated files upon a crash, but then the crash diagnostic process would re-create the file again, and leave it there.
3. Added a test for `#pragma clang __debug llvm_fatal_error` to test for the original issue.
4. Added `llvm::sys::Process::Exit()` and replaced `exit()` in places where it was appropriate. This new function would call the current `CrashRecoveryContext` if one is running on the same thread; or call `exit()` otherwise.

Evidently I can cut the patch in smaller pieces, let me know.

This fixes PR44705.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73742

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Driver/crash-report.c
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/CrashRecoveryContext.h
  llvm/include/llvm/Support/Process.h
  llvm/lib/Support/CrashRecoveryContext.cpp
  llvm/lib/Support/ErrorHandling.cpp
  llvm/lib/Support/Process.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73742.241569.patch
Type: text/x-patch
Size: 16277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200130/ac0475fe/attachment.bin>


More information about the llvm-commits mailing list