[PATCH] D110783: [clang] Make crash reproducer work with clang-cl

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 29 16:00:06 PDT 2021


thakis created this revision.
thakis added a reviewer: hans.
thakis added a project: clang.
thakis requested review of this revision.

When clang crashes, it writes a standalone source file and shell script
to reproduce the crash.

The Driver used to set `Mode = CPPMode` in generateCompilationDiagnostics()
to force preprocessing mode. This has the side effect of making
IsCLMode() return false, which in turn meant Clang::AddClangCLArgs()
didn't get called when creating the standalone source file, which meant
the stand-alone file was preprocessed with the gcc driver's defaults
In particular, exceptions default to on with the gcc driver, but to
off with the cl driver. The .sh script did use the original command
line, so in the reproducer for a clang-cl crash, the standalone source
file could contain exception-using code after preprocessing that the
compiler invocation in the shell script would then complain about.

This patch removes the `Mode = CPPMode;` line and instead additionally
checks for `CCGenDiagnostics` in most places that check `CCCIsCPP().
This also matches the strategy Clang::ConstructJob() uses to add
-frewrite-includes for creating the standalone source file for a crash
report.

Fixes PR52007.


https://reviews.llvm.org/D110783

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report-clang-cl.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report.c
  clang/test/Driver/crash-report.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110783.376059.patch
Type: text/x-patch
Size: 8357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210929/703bfa63/attachment-0001.bin>


More information about the cfe-commits mailing list