diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-10-20 21:02:05 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-10-20 21:02:05 +0000 |
commit | 8d24a336dea9ffac70f50acf16958db1a9212390 (patch) | |
tree | edf5906b031678eba3e25385f6e40ded1522b591 /tools | |
parent | ed84178b858b2ada58f59f3c81df4b5605e1d769 (diff) |
Driver: Make FailingCommand mandatory for generateCompilationDiagnostics
We currently use a null FailingCommand when generating crash reports
as an indication that the cause is FORCE_CLANG_DIAGNOSTICS_CRASH, the
environment variable that exists to test crash dumps. This means that
our tests don't actually cover real crashes at all, and adds a more
complicated code path that's only used in the tests.
Instead, we can have the driver synthesize that every command failed
and just call generateCompilationDiagnostics normally.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220234 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/driver/driver.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 5b42783219..de4b07d214 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -464,8 +464,12 @@ int main(int argc_, const char **argv_) { // Force a crash to test the diagnostics. if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) { Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH"; - const Command *FailingCommand = nullptr; - FailingCommands.push_back(std::make_pair(-1, FailingCommand)); + + // Pretend that every command failed. + FailingCommands.clear(); + for (const auto &J : C->getJobs()) + if (const Command *C = dyn_cast<Command>(&J)) + FailingCommands.push_back(std::make_pair(-1, C)); } for (const auto &P : FailingCommands) { @@ -483,7 +487,7 @@ int main(int argc_, const char **argv_) { DiagnoseCrash |= CommandRes == 3; #endif if (DiagnoseCrash) { - TheDriver.generateCompilationDiagnostics(*C, FailingCommand); + TheDriver.generateCompilationDiagnostics(*C, *FailingCommand); break; } } |