summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-11-02 21:29:05 +0000
committerChad Rosier <mcrosier@apple.com>2011-11-02 21:29:05 +0000
commitcdb008d11719b2d179f45b3fd93b4aef4b01203f (patch)
tree212b21701197038ec486cb05bf3df4b0ece1ebc5 /clang/lib/Driver/Driver.cpp
parentef4ab810d11c85926e4eb07334d3078220893671 (diff)
downloadbcm5719-llvm-cdb008d11719b2d179f45b3fd93b4aef4b01203f.tar.gz
bcm5719-llvm-cdb008d11719b2d179f45b3fd93b4aef4b01203f.zip
In addition to dumping preprocessed source, dump a script with the command line
arguments that caused clang to crash. rdar://8314451 llvm-svn: 143573
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a4aa2ed0250..0a3d69880d7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -373,6 +373,12 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
CCCIsCPP = true;
CCGenDiagnostics = true;
+ // Save the original job command(s).
+ std::string Cmd;
+ llvm::raw_string_ostream OS(Cmd);
+ C.PrintJob(OS, C.getJobs(), "\n", false);
+ OS.flush();
+
// Clear stale state and suppress tool output.
C.initCompilationForDiagnostics();
Diags.Reset();
@@ -449,11 +455,26 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
// If the command succeeded, we are done.
if (Res == 0) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
- << "Preprocessed source(s) are located at:";
+ << "Preprocessed source(s) and associated run script(s) are located at:";
ArgStringList Files = C.getTempFiles();
for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end();
- it != ie; ++it)
+ it != ie; ++it) {
Diag(clang::diag::note_drv_command_failed_diag_msg) << *it;
+
+ std::string Err;
+ std::string Script = StringRef(*it).rsplit('.').first;
+ Script += ".sh";
+ llvm::raw_fd_ostream ScriptOS(Script.c_str(), Err,
+ llvm::raw_fd_ostream::F_Excl |
+ llvm::raw_fd_ostream::F_Binary);
+ if (!Err.empty()) {
+ Diag(clang::diag::note_drv_command_failed_diag_msg)
+ << "Error generating run script: " + Script + " " + Err;
+ } else {
+ ScriptOS << Cmd;
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
+ }
+ }
} else {
// Failure, remove preprocessed files.
if (!C.getArgs().hasArg(options::OPT_save_temps))
OpenPOWER on IntegriCloud