summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-10-20 21:02:05 +0000
committerJustin Bogner <mail@justinbogner.com>2014-10-20 21:02:05 +0000
commite1a33d1e4c925ae4cfe36df13475e56762780360 (patch)
treeb272a85f211c8acbdf3f03ca29802420f4b9fff7 /clang
parent204607bc90b6ff4aaff96a078efa50486babb393 (diff)
downloadbcm5719-llvm-e1a33d1e4c925ae4cfe36df13475e56762780360.tar.gz
bcm5719-llvm-e1a33d1e4c925ae4cfe36df13475e56762780360.zip
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. llvm-svn: 220234
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Driver/Driver.h2
-rw-r--r--clang/lib/Driver/Driver.cpp13
-rw-r--r--clang/tools/driver/driver.cpp10
3 files changed, 12 insertions, 13 deletions
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index aea857dbc21..bd672446ac4 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -304,7 +304,7 @@ public:
/// including preprocessed source file(s).
///
void generateCompilationDiagnostics(Compilation &C,
- const Command *FailingCommand);
+ const Command &FailingCommand);
/// @}
/// @name Helper Methods
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 89713f59ea6..a7a5b1ed0a0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -403,13 +403,13 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// preprocessed source file(s). Request that the developer attach the
// diagnostic information to a bug report.
void Driver::generateCompilationDiagnostics(Compilation &C,
- const Command *FailingCommand) {
+ const Command &FailingCommand) {
if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
return;
// Don't try to generate diagnostics for link or dsymutil jobs.
- if (FailingCommand && (FailingCommand->getCreator().isLinkJob() ||
- FailingCommand->getCreator().isDsymutilJob()))
+ if (FailingCommand.getCreator().isLinkJob() ||
+ FailingCommand.getCreator().isDsymutilJob())
return;
// Print the version of the compiler.
@@ -426,12 +426,7 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
// Save the original job command(s).
std::string Cmd;
llvm::raw_string_ostream OS(Cmd);
- if (FailingCommand)
- FailingCommand->Print(OS, "\n", /*Quote*/ false, /*CrashReport*/ true);
- else
- // Crash triggered by FORCE_CLANG_DIAGNOSTICS_CRASH, which doesn't have an
- // associated FailingCommand, so just pass all jobs.
- C.getJobs().Print(OS, "\n", /*Quote*/ false, /*CrashReport*/ true);
+ FailingCommand.Print(OS, "\n", /*Quote*/ false, /*CrashReport*/ true);
OS.flush();
// Keep track of whether we produce any errors while trying to produce
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 5b427832190..de4b07d2141 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/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;
}
}
OpenPOWER on IntegriCloud