[PATCH] D43888: [clang-cl] Implement /X

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 11:17:10 PST 2018


thakis created this revision.
thakis added a reviewer: hans.

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs() for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed by clang-cl), so just alias /X to that.


https://reviews.llvm.org/D43888

Files:
  include/clang/Driver/CLCompatOptions.td
  test/Driver/cl-include.c


Index: test/Driver/cl-include.c
===================================================================
--- test/Driver/cl-include.c
+++ test/Driver/cl-include.c
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"
Index: include/clang/Driver/CLCompatOptions.td
===================================================================
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -164,6 +164,9 @@
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias<vtordisp_mode_EQ>;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias<nostdlibinc>;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias<fsized_deallocation>;
@@ -386,7 +389,6 @@
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43888.136348.patch
Type: text/x-patch
Size: 2161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180228/a0f0aea1/attachment.bin>


More information about the cfe-commits mailing list