if (D.CCGenDiagnostics)
CmdArgs.push_back("-disable-pragma-debug-crash");
+ // Allow backend to put its diagnostic files in the same place as frontend
+ // crash diagnostics files.
+ if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) {
+ StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir);
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir));
+ }
+
bool UseSeparateSections = isUseSeparateSections(Triple);
if (Args.hasFlag(options::OPT_ffunction_sections,
--- /dev/null
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=OPTION
+// OPTION: "-crash-diagnostics-dir=mydumps"
+// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
+// NOOPTION-NOT: "-crash-diagnostics-dir
DisableSymbolication("disable-symbolication",
cl::desc("Disable symbolizing crash backtraces."),
cl::location(DisableSymbolicationFlag), cl::Hidden);
+static std::string CrashDiagnosticsDirectory;
+static cl::opt<std::string, true>
+ CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"),
+ cl::desc("Directory for crash diagnostic files."),
+ cl::location(CrashDiagnosticsDirectory), cl::Hidden);
constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
DumpType = MiniDumpNormal;
- // Look to see if a dump location is specified in the registry; first with the
+ // Look to see if a dump location is specified on the command line. If not,
+ // look to see if a dump location is specified in the registry; first with the
// app-specific key and failing that with the global key. If none are found
// we'll just create the dump file in the default temporary file location
// (GetDumpFolder will return false either if the key is NULL or if there is
// no valid DumpFolder value at its location).
bool ExplicitDumpDirectorySet = true;
- SmallString<MAX_PATH> DumpDirectory;
- if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
- if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
- ExplicitDumpDirectorySet = false;
+ SmallString<MAX_PATH> DumpDirectory(CrashDiagnosticsDirectory);
+ if (DumpDirectory.empty())
+ if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
+ if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
+ ExplicitDumpDirectorySet = false;
int FD;
SmallString<MAX_PATH> DumpPath;