[cfe-commits] r143573 - /cfe/trunk/lib/Driver/Driver.cpp

Chad Rosier mcrosier at apple.com
Wed Nov 2 14:29:05 PDT 2011


Author: mcrosier
Date: Wed Nov  2 16:29:05 2011
New Revision: 143573

URL: http://llvm.org/viewvc/llvm-project?rev=143573&view=rev
Log:
In addition to dumping preprocessed source, dump a script with the command line
arguments that caused clang to crash.
rdar://8314451

Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=143573&r1=143572&r2=143573&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov  2 16:29:05 2011
@@ -373,6 +373,12 @@
   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 @@
   // 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))





More information about the cfe-commits mailing list