diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp index d44458db2fbe..2d99b1f22385 100644 --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -41,17 +41,16 @@ static int skipArgs(const char *Flag, bool HaveCrashVFS) { // These flags are all of the form -Flag and are treated as two // arguments. Therefore, we need to skip the flag and the next argument. bool Res = llvm::StringSwitch(Flag) - .Cases("-I", "-MF", "-MT", "-MQ", true) + .Cases("-MF", "-MT", "-MQ", "-serialize-diagnostic-file", true) .Cases("-o", "-coverage-file", "-dependency-file", true) .Cases("-fdebug-compilation-dir", "-idirafter", true) .Cases("-include", "-include-pch", "-internal-isystem", true) .Cases("-internal-externc-isystem", "-iprefix", "-iwithprefix", true) .Cases("-iwithprefixbefore", "-isystem", "-iquote", true) - .Cases("-resource-dir", "-serialize-diagnostic-file", true) .Cases("-dwarf-debug-flags", "-ivfsoverlay", true) .Cases("-header-include-file", "-diagnostic-log-file", true) // Some include flags shouldn't be skipped if we have a crash VFS - .Case("-isysroot", !HaveCrashVFS) + .Cases("-isysroot", "-I", "-F", "-resource-dir", !HaveCrashVFS) .Default(false); // Match found. @@ -72,7 +71,8 @@ static int skipArgs(const char *Flag, bool HaveCrashVFS) { // These flags are treated as a single argument (e.g., -F). StringRef FlagRef(Flag); - if (FlagRef.startswith("-F") || FlagRef.startswith("-I") || + if ((!HaveCrashVFS && + (FlagRef.startswith("-F") || FlagRef.startswith("-I"))) || FlagRef.startswith("-fmodules-cache-path=")) return 1; diff --git a/clang/test/Modules/crash-vfs-relative-overlay.m b/clang/test/Modules/crash-vfs-relative-overlay.m index d157b1339251..29552d0bb346 100644 --- a/clang/test/Modules/crash-vfs-relative-overlay.m +++ b/clang/test/Modules/crash-vfs-relative-overlay.m @@ -7,8 +7,9 @@ // RUN: mkdir -p %t/i %t/m %t // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ -// RUN: %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \ -// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s +// RUN: %clang -fsyntax-only -nostdinc %s \ +// RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \ +// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s // RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh @@ -17,7 +18,7 @@ // RUN: find %t/crash-vfs-*.cache/vfs | \ // RUN: grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1 -#include "usr/include/stdio.h" +#include // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.m @@ -29,8 +30,8 @@ // CHECKSH-NEXT: # Driver args: "-fsyntax-only" // CHECKSH-NEXT: # Original command: {{.*$}} // CHECKSH-NEXT: "-cc1" +// CHECKSH: "-resource-dir" // CHECKSH: "-isysroot" "{{[^"]*}}/i/" -// CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" @@ -49,7 +50,7 @@ // the overlay dir is prefixed to access headers in .cache/vfs directory. // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH -// RUN: %clang -E %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \ +// RUN: %clang -E %s -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \ // RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \ // RUN: -fmodules-cache-path=%t/m/ 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY