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)
.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.
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 &&
PrintArg(OS, Arg, Quote);
}
- if (CrashInfo && !CrashInfo->VFSPath.empty()) {
+ if (CrashInfo && HaveCrashVFS) {
OS << ' ';
PrintArg(OS, "-ivfsoverlay", Quote);
OS << ' ';
// 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
// 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"