[all-commits] [llvm/llvm-project] 8dfbe9: [clang] Make crash reproducer work with clang-cl

Nico Weber via All-commits all-commits at lists.llvm.org
Thu Sep 30 11:33:36 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8dfbe9b0aeb6d45975d453dfed828068c63c225e
      https://github.com/llvm/llvm-project/commit/8dfbe9b0aeb6d45975d453dfed828068c63c225e
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-09-30 (Thu, 30 Sep 2021)

  Changed paths:
    M clang/lib/Driver/Driver.cpp
    R clang/test/Driver/crash-report-clang-cl.c
    A clang/test/Driver/crash-report-clang-cl.cpp
    R clang/test/Driver/crash-report.c
    A clang/test/Driver/crash-report.cpp

  Log Message:
  -----------
  [clang] Make crash reproducer work with clang-cl

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.

Differential Revision: https://reviews.llvm.org/D110783




More information about the All-commits mailing list