summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-05-04 00:55:14 +0000
committerPetr Hosek <phosek@chromium.org>2019-05-04 00:55:14 +0000
commitbd2061a19606a27c81bacdd54da40fb5736945c2 (patch)
tree792694d2245408e0ffb866a8bb6acdd4c7a707d6
parent67a39e27344295335e733eab5b576c397ebffd4c (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359954 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Driver/Driver.cpp2
-rw-r--r--test/Driver/crash-diagnostics-dir.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 238315e8b9..06c0e3bdb3 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -4263,6 +4263,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
if (CCGenDiagnostics && A) {
SmallString<128> CrashDirectory(A->getValue());
+ if (!getVFS().exists(CrashDirectory))
+ llvm::sys::fs::create_directories(CrashDirectory);
llvm::sys::path::append(CrashDirectory, Split.first);
const char *Middle = Suffix ? "-%%%%%%." : "-%%%%%%";
std::error_code EC = llvm::sys::fs::createUniqueFile(
diff --git a/test/Driver/crash-diagnostics-dir.c b/test/Driver/crash-diagnostics-dir.c
index c8faf497b5..44c4af6764 100644
--- a/test/Driver/crash-diagnostics-dir.c
+++ b/test/Driver/crash-diagnostics-dir.c
@@ -1,5 +1,4 @@
// RUN: rm -rf %t
-// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at: