summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-03-12 00:52:56 +0000
committerJustin Bogner <mail@justinbogner.com>2015-03-12 00:52:56 +0000
commit0cb14759fcf9493075f97e60c28ce19c6a827f72 (patch)
tree51e47fb2221517af4111a214a0421b8f7d6f8e3a
parent325297c1015c147798626ab58d7b8335b73053f3 (diff)
downloadbcm5719-llvm-0cb14759fcf9493075f97e60c28ce19c6a827f72.tar.gz
bcm5719-llvm-0cb14759fcf9493075f97e60c28ce19c6a827f72.zip
Driver: Keep -isysroot flags in crash scripts if we're dumping a VFS
For crashes with a VFS (ie, with modules), the -isysroot flag is often necessary to reproduce the crash. This is especially true if some modules need to be rebuilt, since without the sysroot they'll try to read headers that are outside of the VFS. I find it likely that we should keep some of the other -i flags in this case as well, but I haven't seen that come up in practice yet so it seems better to be conservative. llvm-svn: 231997
-rw-r--r--clang/lib/Driver/Job.cpp11
-rw-r--r--clang/test/Driver/crash-report-modules.m3
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 66434cf7b01..6d18a41cad0 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -34,7 +34,7 @@ Command::Command(const Action &_Source, const Tool &_Creator,
Executable(_Executable), Arguments(_Arguments),
ResponseFile(nullptr) {}
-static int skipArgs(const char *Flag) {
+static int skipArgs(const char *Flag, bool HaveCrashVFS) {
// These flags are all of the form -Flag <Arg> and are treated as two
// arguments. Therefore, we need to skip the flag and the next argument.
bool Res = llvm::StringSwitch<bool>(Flag)
@@ -43,9 +43,11 @@ static int skipArgs(const char *Flag) {
.Cases("-fdebug-compilation-dir", "-idirafter", true)
.Cases("-include", "-include-pch", "-internal-isystem", true)
.Cases("-internal-externc-isystem", "-iprefix", "-iwithprefix", true)
- .Cases("-iwithprefixbefore", "-isysroot", "-isystem", "-iquote", true)
+ .Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
.Cases("-resource-dir", "-serialize-diagnostic-file", true)
.Cases("-dwarf-debug-flags", "-ivfsoverlay", true)
+ // Some include flags shouldn't be skipped if we have a crash VFS
+ .Case("-isysroot", !HaveCrashVFS)
.Default(false);
// Match found.
@@ -164,11 +166,12 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
if (StringRef(Args[I]).equals("-main-file-name"))
MainFilename = Args[I + 1];
+ bool HaveCrashVFS = CrashInfo && !CrashInfo->VFSPath.empty();
for (size_t i = 0, e = Args.size(); i < e; ++i) {
const char *const Arg = Args[i];
if (CrashInfo) {
- if (int Skip = skipArgs(Arg)) {
+ if (int Skip = skipArgs(Arg, HaveCrashVFS)) {
i += Skip - 1;
continue;
} else if (llvm::sys::path::filename(Arg) == MainFilename &&
@@ -185,7 +188,7 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
PrintArg(OS, Arg, Quote);
}
- if (CrashInfo && !CrashInfo->VFSPath.empty()) {
+ if (CrashInfo && HaveCrashVFS) {
OS << ' ';
PrintArg(OS, "-ivfsoverlay", Quote);
OS << ' ';
diff --git a/clang/test/Driver/crash-report-modules.m b/clang/test/Driver/crash-report-modules.m
index dab92311e71..66ebaa750dd 100644
--- a/clang/test/Driver/crash-report-modules.m
+++ b/clang/test/Driver/crash-report-modules.m
@@ -2,7 +2,7 @@
// RUN: mkdir %t
// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
-// RUN: %clang -fsyntax-only %s -I %S/Inputs/module \
+// RUN: %clang -fsyntax-only %s -I %S/Inputs/module -isysroot /tmp/ \
// RUN: -fmodules -fmodules-cache-path=/tmp/ -DFOO=BAR 2>&1 | FileCheck %s
// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-report-*.m
@@ -28,6 +28,7 @@ const int x = MODULE_MACRO;
// CHECKSH: # Crash reproducer
// CHECKSH-NEXT: # Original command: {{.*$}}
// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-isysroot" "/tmp/"
// CHECKSH: "-D" "FOO=BAR"
// CHECKSH-NOT: "-fmodules-cache-path=/tmp/"
// CHECKSH: "crash-report-modules-{{[^ ]*}}.m"
OpenPOWER on IntegriCloud