[Driver] Create non-existent directory for -fcrash-diagnostics-dir

When user specifies non-existent directory to -fcrash-diagnostics-dir,
create it rather than failing with an error as would be the case before.

Differential Revision: https://reviews.llvm.org/D61542

llvm-svn: 359954
This commit is contained in:
Petr Hosek 2019-05-04 00:55:14 +00:00
parent 3c7688bd57
commit 1e393064fa
2 changed files with 2 additions and 1 deletions

View File

@ -4263,6 +4263,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir); Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
if (CCGenDiagnostics && A) { if (CCGenDiagnostics && A) {
SmallString<128> CrashDirectory(A->getValue()); SmallString<128> CrashDirectory(A->getValue());
if (!getVFS().exists(CrashDirectory))
llvm::sys::fs::create_directories(CrashDirectory);
llvm::sys::path::append(CrashDirectory, Split.first); llvm::sys::path::append(CrashDirectory, Split.first);
const char *Middle = Suffix ? "-%%%%%%." : "-%%%%%%"; const char *Middle = Suffix ? "-%%%%%%." : "-%%%%%%";
std::error_code EC = llvm::sys::fs::createUniqueFile( std::error_code EC = llvm::sys::fs::createUniqueFile(

View File

@ -1,5 +1,4 @@
// RUN: rm -rf %t // RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s // RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
#pragma clang __debug parser_crash #pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK: Preprocessed source(s) and associated run script(s) are located at: