Driver: honor -nostdinc and -isystem-after on CrossWindows

This changes CrossWindows to look for -nostdinc instead of -nostdlibinc.
In addition, fixes a bug where -isystem-after options would be dropped
when called with -nostdinc.

Patch by Dave Lee!

llvm-svn: 306829
This commit is contained in:
Saleem Abdulrasool 2017-06-30 15:15:38 +00:00
parent 8843aab83a
commit a517a0a520
2 changed files with 15 additions and 4 deletions

View File

@ -238,8 +238,15 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
const Driver &D = getDriver();
const std::string &SysRoot = D.SysRoot;
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
auto AddSystemAfterIncludes = [&]() {
for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
addSystemInclude(DriverArgs, CC1Args, P);
};
if (DriverArgs.hasArg(options::OPT_nostdinc)) {
AddSystemAfterIncludes();
return;
}
addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
@ -247,8 +254,7 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::sys::path::append(ResourceDir, "include");
addSystemInclude(DriverArgs, CC1Args, ResourceDir);
}
for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
addSystemInclude(DriverArgs, CC1Args, P);
AddSystemAfterIncludes();
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
}
@ -258,7 +264,7 @@ AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
const llvm::Triple &Triple = getTriple();
const std::string &SysRoot = getDriver().SysRoot;
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;

View File

@ -80,3 +80,8 @@
// CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
// CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after "Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
// CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"