Author: nico Date: Tue Apr 12 14:04:37 2016 New Revision: 266108 URL: http://llvm.org/viewvc/llvm-project?rev=266108&view=rev Log: clang-cl: Remove -isystem, add -imsvc.
r260990 exposed -isystem in clang-cl. -isystem adds a directory to the front of the system include search path. The idea was to use this to point to a hermetic msvc install, but as it turns out this doesn't work: -isystem then adds the hermetic headers in front of clang's builtin headers, and clang's headers that are supposed to wrap msvc headers (say, stdarg.h) aren't picked up at all anymore. So revert that, and instead expose -imsvc which works as if the passed directory was part of %INCLUDE%: The header is treated as a system header, but it is searched after clang's lib/Header headers. Fixes half of PRPR26751. Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/MSVCToolChain.cpp cfe/trunk/test/Driver/cl-options.c cfe/trunk/test/Driver/cl-pch-search.cpp Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=266108&r1=266107&r2=266108&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Apr 12 14:04:37 2016 @@ -210,6 +210,9 @@ def _SLASH_GX : CLFlag<"GX">, HelpText<"Enable exception handling">; def _SLASH_GX_ : CLFlag<"GX-">, HelpText<"Enable exception handling">; +def _SLASH_imsvc : CLJoinedOrSeparate<"imsvc">, + HelpText<"Add directory to system include search path, as if part of %INCLUDE%">, + MetaVarName<"<dir>">; def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">; def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">; def _SLASH_link : CLRemainingArgs<"link">, Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=266108&r1=266107&r2=266108&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 12 14:04:37 2016 @@ -1254,7 +1254,7 @@ def iquote : JoinedOrSeparate<["-"], "iq def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group<clang_i_Group>, Flags<[CC1Option]>, HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">; def isystem : JoinedOrSeparate<["-"], "isystem">, Group<clang_i_Group>, - Flags<[CC1Option, CoreOption]>, + Flags<[CC1Option]>, HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"<directory>">; def iwithprefixbefore : JoinedOrSeparate<["-"], "iwithprefixbefore">, Group<clang_i_Group>, HelpText<"Set directory to include search path with prefix">, MetaVarName<"<dir>">, Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=266108&r1=266107&r2=266108&view=diff ============================================================================== --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original) +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue Apr 12 14:04:37 2016 @@ -527,6 +527,10 @@ void MSVCToolChain::AddClangSystemInclud "include"); } + // Add %INCLUDE%-like directories from the -imsvc flag. + for (const auto &Path : DriverArgs.getAllArgValues(options::OPT__SLASH_imsvc)) + addSystemInclude(DriverArgs, CC1Args, Path); + if (DriverArgs.hasArg(options::OPT_nostdlibinc)) return; Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=266108&r1=266107&r2=266108&view=diff ============================================================================== --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Tue Apr 12 14:04:37 2016 @@ -82,6 +82,12 @@ // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s // SLASH_I: "-I" "myincludedir" +// RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s +// RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s +// Clang's resource header directory should be first: +// SLASH_imsvc: "-internal-isystem" "{{[^"]*}}lib{{.}}clang{{[^"]*}}include" +// SLASH_imsvc: "-internal-isystem" "myincludedir" + // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s // J: -fno-signed-char @@ -452,7 +458,6 @@ // RUN: -fno-ms-compatibility \ // RUN: -fms-extensions \ // RUN: -fno-ms-extensions \ -// RUN: -isystem=some/path \ // RUN: -mllvm -disable-llvm-optzns \ // RUN: -Wunused-variable \ // RUN: -fmacro-backtrace-limit=0 \ Modified: cfe/trunk/test/Driver/cl-pch-search.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-search.cpp?rev=266108&r1=266107&r2=266108&view=diff ============================================================================== --- cfe/trunk/test/Driver/cl-pch-search.cpp (original) +++ cfe/trunk/test/Driver/cl-pch-search.cpp Tue Apr 12 14:04:37 2016 @@ -4,7 +4,3 @@ // REQUIRES: x86-registered-target // Check that pchfile.h next to to pchfile.cc is found correctly. // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp - -// Check that i_group flags other than -include aren't skipped (e.g. -isystem). -#include "header0.h" -// RUN: %clang_cl -Werror -isystem%S/Inputs /Yupchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- %s _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits