r220241 - Driver: Consolidate the logic for naming the module crashdump cache

Justin Bogner mail at justinbogner.com
Mon Oct 20 15:47:23 PDT 2014


Author: bogner
Date: Mon Oct 20 17:47:23 2014
New Revision: 220241

URL: http://llvm.org/viewvc/llvm-project?rev=220241&view=rev
Log:
Driver: Consolidate the logic for naming the module crashdump cache

List the module cache we use for crashdumps as a tempfile. This
simplifies how we pick up this directory when generating the actual
crash diagnostic and removes some duplicate logic.

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=220241&r1=220240&r2=220241&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Oct 20 17:47:23 2014
@@ -529,27 +529,22 @@ void Driver::generateCompilationDiagnost
          "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
          "Preprocessed source(s) and associated run script(s) are located at:";
 
-  for (const char *TempFile : TempFiles)
+  SmallString<128> VFS;
+  for (const char *TempFile : TempFiles) {
     Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
+    if (StringRef(TempFile).endswith(".cache")) {
+      // In some cases (modules) we'll dump extra data to help with reproducing
+      // the crash into a directory next to the output.
+      VFS = llvm::sys::path::filename(TempFile);
+      llvm::sys::path::append(VFS, "vfs", "vfs.yaml");
+    }
+  }
 
   // Assume associated files are based off of the first temporary file.
   const char *MainFile = TempFiles[0];
 
-  std::string Script = StringRef(MainFile).rsplit('.').first;
-
-  // In some cases (modules) we'll dump extra data to help with reproducing
-  // the crash into a directory next to the output.
-  // FIXME: We should be able to generate these as extra temp files now that it
-  // won't mess up the run script.
-  SmallString<128> VFS;
-  if (llvm::sys::fs::exists(Script + ".cache")) {
-    Diag(clang::diag::note_drv_command_failed_diag_msg) << Script + ".cache";
-    VFS = llvm::sys::path::filename(Script + ".cache");
-    llvm::sys::path::append(VFS, "vfs", "vfs.yaml");
-  }
-
+  std::string Script = StringRef(MainFile).rsplit('.').first.str() + ".sh";
   std::error_code EC;
-  Script += ".sh";
   llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::F_Excl);
   if (EC) {
     Diag(clang::diag::note_drv_command_failed_diag_msg)

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=220241&r1=220240&r2=220241&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 20 17:47:23 2014
@@ -3860,6 +3860,9 @@ void Clang::ConstructJob(Compilation &C,
   if (HaveModules && C.isForDiagnostics()) {
     SmallString<128> VFSDir(Output.getFilename());
     llvm::sys::path::replace_extension(VFSDir, ".cache");
+    // Add the cache directory as a temp so the crash diagnostics pick it up.
+    C.addTempFile(Args.MakeArgString(VFSDir));
+
     llvm::sys::path::append(VFSDir, "vfs");
     CmdArgs.push_back("-module-dependency-dir");
     CmdArgs.push_back(Args.MakeArgString(VFSDir));





More information about the cfe-commits mailing list