From: Saleem Abdulrasool Date: Fri, 30 Jun 2017 15:15:38 +0000 (+0000) Subject: Driver: honor -nostdinc and -isystem-after on CrossWindows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0375288466e510a35fda999e37053ab13a79ea89;p=clang 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306829 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/CrossWindows.cpp b/lib/Driver/ToolChains/CrossWindows.cpp index d290c62a05..7d0c438b13 100644 --- a/lib/Driver/ToolChains/CrossWindows.cpp +++ b/lib/Driver/ToolChains/CrossWindows.cpp @@ -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; diff --git a/test/Driver/windows-cross.c b/test/Driver/windows-cross.c index 90fefbadfe..0e688f0a26 100644 --- a/test/Driver/windows-cross.c +++ b/test/Driver/windows-cross.c @@ -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"