9898#include " llvm/Support/IOSandbox.h"
9999#include " llvm/Support/JSON.h"
100100#include " llvm/Support/MD5.h"
101- #include " llvm/Support/MemoryBuffer.h"
102101#include " llvm/Support/Path.h"
103102#include " llvm/Support/PrettyStackTrace.h"
104103#include " llvm/Support/Process.h"
105104#include " llvm/Support/Program.h"
106105#include " llvm/Support/Regex.h"
107106#include " llvm/Support/StringSaver.h"
108- #include " llvm/Support/TarWriter.h"
109107#include " llvm/Support/VirtualFileSystem.h"
110108#include " llvm/Support/raw_ostream.h"
111109#include " llvm/TargetParser/Host.h"
@@ -1964,9 +1962,10 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
19641962 return false ;
19651963}
19661964
1967- static const char BugReportMsg [] =
1965+ static const char BugReporMsg [] =
19681966 " \n ********************\n\n "
1969- " PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:" ;
1967+ " PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n "
1968+ " Preprocessed source(s) and associated run script(s) are located at:" ;
19701969
19711970// When clang crashes, produce diagnostic information including the fully
19721971// preprocessed source file(s). Request that the developer attach the
@@ -1977,8 +1976,6 @@ void Driver::generateCompilationDiagnostics(
19771976 if (C.getArgs ().hasArg (options::OPT_fno_crash_diagnostics))
19781977 return ;
19791978
1980- bool HasCrashTar = C.getArgs ().hasArg (options::OPT_fcrash_diagnostics_tar);
1981-
19821979 unsigned Level = 1 ;
19831980 if (Arg *A = C.getArgs ().getLastArg (options::OPT_fcrash_diagnostics_EQ)) {
19841981 Level = llvm::StringSwitch<unsigned >(A->getValue ())
@@ -2039,7 +2036,7 @@ void Driver::generateCompilationDiagnostics(
20392036
20402037 // Redirect stdout/stderr to /dev/null.
20412038 NewLLDInvocation.Execute ({std::nullopt , {" " }, {" " }}, nullptr , nullptr );
2042- Diag (clang::diag::note_drv_command_failed_diag_msg) << BugReportMsg ;
2039+ Diag (clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg ;
20432040 Diag (clang::diag::note_drv_command_failed_diag_msg) << TmpName;
20442041 Diag (clang::diag::note_drv_command_failed_diag_msg)
20452042 << " \n\n ********************" ;
@@ -2180,13 +2177,12 @@ void Driver::generateCompilationDiagnostics(
21802177 TempFiles.push_back (std::string (Path.begin (), Path.end ()));
21812178 }
21822179
2183- Diag (clang::diag::note_drv_command_failed_diag_msg) << BugReportMsg ;
2180+ Diag (clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg ;
21842181
21852182 SmallString<128 > VFS;
21862183 SmallString<128 > ReproCrashFilename;
21872184 for (std::string &TempFile : TempFiles) {
2188- if (!HasCrashTar)
2189- Diag (clang::diag::note_drv_command_failed_diag_msg) << TempFile;
2185+ Diag (clang::diag::note_drv_command_failed_diag_msg) << TempFile;
21902186 if (Report)
21912187 Report->TemporaryFiles .push_back (TempFile);
21922188 if (ReproCrashFilename.empty ()) {
@@ -2228,69 +2224,7 @@ void Driver::generateCompilationDiagnostics(
22282224 << " \n " ;
22292225 if (Report)
22302226 Report->TemporaryFiles .push_back (std::string (Script));
2231- TempFiles.push_back (std::string (Script));
2232- ScriptOS.close ();
2233- if (!HasCrashTar)
2234- Diag (clang::diag::note_drv_command_failed_diag_msg) << Script;
2235- }
2236-
2237- if (Arg *A = C.getArgs ().getLastArg (options::OPT_fcrash_diagnostics_tar)) {
2238- StringRef CrashDiagnosticsTar = A->getValue ();
2239- Expected<std::unique_ptr<llvm::TarWriter>> TarOrErr =
2240- llvm::TarWriter::create (CrashDiagnosticsTar,
2241- llvm::sys::path::stem (CrashDiagnosticsTar));
2242- if (!TarOrErr) {
2243- Diag (clang::diag::note_drv_command_failed_diag_msg)
2244- << (std::string (" Error creating reproducer tarball: " ) +
2245- llvm::toString (TarOrErr.takeError ()));
2246- } else {
2247- std::unique_ptr<llvm::TarWriter> &Tar = *TarOrErr;
2248- for (const std::string &TempFile : TempFiles) {
2249- if (llvm::sys::fs::is_directory (TempFile)) {
2250- std::error_code EC;
2251- for (llvm::sys::fs::recursive_directory_iterator I (TempFile, EC), E;
2252- I != E && !EC; I.increment (EC)) {
2253- if (llvm::sys::fs::is_regular_file (I->path ())) {
2254- auto BufferOrErr = llvm::MemoryBuffer::getFile (I->path ());
2255- if (BufferOrErr) {
2256- // Construct path of file relative to TempFile.
2257- llvm::SmallString<128 > PathInTar =
2258- llvm::sys::path::filename (TempFile);
2259- StringRef SubPath = I->path ();
2260- if (SubPath.consume_front (TempFile)) {
2261- if (!SubPath.empty () &&
2262- llvm::sys::path::is_separator (SubPath.front ())) {
2263- SubPath = SubPath.drop_front ();
2264- }
2265- llvm::sys::path::append (PathInTar, SubPath);
2266- Tar->append (PathInTar, (*BufferOrErr)->getBuffer ());
2267- }
2268- } else {
2269- Diag (clang::diag::note_drv_command_failed_diag_msg)
2270- << (std::string (" Error reading file for tarball: " ) +
2271- I->path ());
2272- }
2273- }
2274- }
2275- if (EC) {
2276- Diag (clang::diag::note_drv_command_failed_diag_msg)
2277- << (std::string (" Error iterating directory for tarball: " ) +
2278- TempFile + " " + EC.message ());
2279- }
2280- } else {
2281- auto BufferOrErr = llvm::MemoryBuffer::getFile (TempFile);
2282- if (BufferOrErr) {
2283- Tar->append (llvm::sys::path::filename (TempFile),
2284- (*BufferOrErr)->getBuffer ());
2285- } else {
2286- Diag (clang::diag::note_drv_command_failed_diag_msg)
2287- << (std::string (" Error reading file for tarball: " ) + TempFile);
2288- }
2289- }
2290- }
2291- Diag (clang::diag::note_drv_command_failed_diag_msg)
2292- << CrashDiagnosticsTar;
2293- }
2227+ Diag (clang::diag::note_drv_command_failed_diag_msg) << Script;
22942228 }
22952229
22962230 // On darwin, provide information about the .crash diagnostic report.
0 commit comments