summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-10-20 21:47:56 +0000
committerJustin Bogner <mail@justinbogner.com>2014-10-20 21:47:56 +0000
commitc1fdf7fa111f9a153a67e69d75f843ac89ce8d27 (patch)
tree23a7d5cf3402d8908db0c9ba758d49bc6726951c /clang/lib/Driver/Driver.cpp
parentc71e0050304e5d259c075b890627108b489299f3 (diff)
downloadbcm5719-llvm-c1fdf7fa111f9a153a67e69d75f843ac89ce8d27.tar.gz
bcm5719-llvm-c1fdf7fa111f9a153a67e69d75f843ac89ce8d27.zip
Driver: Name crashdump scripts after the first temp file
In practice there's only ever one temporary output file when generating a crashdump, but even if there were many iterating over each and creating a duplicate run script for each one wouldn't make very much sense. This updates the behaviour to only generate the script once, based on the first filename. This should make it more reasonable to generate extra output files to include in the crashdump going forward, so I've also added a FIXME to look into doing just that with the extra module crashdump files. llvm-svn: 220238
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp96
1 files changed, 54 insertions, 42 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 82226405a4f..30ae6ffebcb 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -517,54 +517,66 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
return;
}
+ const ArgStringList &TempFiles = C.getTempFiles();
+ if (TempFiles.empty()) {
+ Diag(clang::diag::note_drv_command_failed_diag_msg)
+ << "Error generating preprocessed source(s).";
+ return;
+ }
+
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "\n********************\n\n"
"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
"Preprocessed source(s) and associated run script(s) are located at:";
- const ArgStringList &Files = C.getTempFiles();
- for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end();
- it != ie; ++it) {
- Diag(clang::diag::note_drv_command_failed_diag_msg) << *it;
- std::string Script = StringRef(*it).rsplit('.').first;
- // In some cases (modules) we'll dump extra data to help with reproducing
- // the crash into a directory next to the output.
- 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::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)
- << "Error generating run script: " + Script + " " + EC.message();
- } else {
- // Replace the original filename with the preprocessed one.
- size_t I, E;
- I = Cmd.find("-main-file-name ");
- assert(I != std::string::npos && "Expected to find -main-file-name");
- I += 16;
- E = Cmd.find(" ", I);
- assert(E != std::string::npos && "-main-file-name missing argument?");
- StringRef OldFilename = StringRef(Cmd).slice(I, E);
- StringRef NewFilename = llvm::sys::path::filename(*it);
- I = StringRef(Cmd).rfind(OldFilename);
- E = I + OldFilename.size();
- if (E + 1 < Cmd.size() && Cmd[E] == '"')
- ++E; // Replace a trailing quote if present.
- I = Cmd.rfind(" ", I) + 1;
- Cmd.replace(I, E - I, NewFilename.data(), NewFilename.size());
- if (!VFS.empty()) {
- // Add the VFS overlay to the reproduction script.
- I += NewFilename.size();
- Cmd.insert(I, std::string(" -ivfsoverlay ") + VFS.c_str());
- }
- ScriptOS << Cmd;
- Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
+ for (const char *TempFile : TempFiles)
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
+
+ // 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::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)
+ << "Error generating run script: " + Script + " " + EC.message();
+ } else {
+ // Replace the original filename with the preprocessed one.
+ size_t I, E;
+ I = Cmd.find("-main-file-name ");
+ assert(I != std::string::npos && "Expected to find -main-file-name");
+ I += 16;
+ E = Cmd.find(" ", I);
+ assert(E != std::string::npos && "-main-file-name missing argument?");
+ StringRef OldFilename = StringRef(Cmd).slice(I, E);
+ StringRef NewFilename = llvm::sys::path::filename(MainFile);
+ I = StringRef(Cmd).rfind(OldFilename);
+ E = I + OldFilename.size();
+ if (E + 1 < Cmd.size() && Cmd[E] == '"')
+ ++E; // Replace a trailing quote if present.
+ I = Cmd.rfind(" ", I) + 1;
+ Cmd.replace(I, E - I, NewFilename.data(), NewFilename.size());
+ if (!VFS.empty()) {
+ // Add the VFS overlay to the reproduction script.
+ I += NewFilename.size();
+ Cmd.insert(I, std::string(" -ivfsoverlay ") + VFS.c_str());
}
+ ScriptOS << Cmd;
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
}
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "\n\n********************";
OpenPOWER on IntegriCloud