diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -36,7 +36,8 @@ FC1Option = (1 << 15), FlangOnlyOption = (1 << 16), DXCOption = (1 << 17), - Ignored = (1 << 18), + CLDXCOption = (1 << 18), + Ignored = (1 << 19), }; enum ID { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -53,6 +53,10 @@ // are made available when the driver is running in DXC compatibility mode. def DXCOption : OptionFlag; +// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag +// are made available when the driver is running in CL/DXC compatibility mode. +def CLDXCOption : OptionFlag; + // NoDriverOption - This option should not be accepted by the driver. def NoDriverOption : OptionFlag; @@ -6309,6 +6313,9 @@ def cl_Group : OptionGroup<"">, Flags<[CLOption]>, HelpText<"CL.EXE COMPATIBILITY OPTIONS">; +def cl_dxc_Group : OptionGroup<"">, Flags<[CLDXCOption]>, + HelpText<"CL.EXE COMPATIBILITY OPTIONS">; + def cl_compile_Group : OptionGroup<"">, Group; @@ -6336,6 +6343,9 @@ class CLJoinedOrSeparate : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>; +class CLDXCJoinedOrSeparate : Option<["/", "-"], name, + KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>; + class CLCompileJoinedOrSeparate : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>; @@ -6413,7 +6423,7 @@ def _SLASH_HELP : CLFlag<"HELP">, Alias; def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias, HelpText<"Create hotpatchable image">; -def _SLASH_I : CLJoinedOrSeparate<"I">, +def _SLASH_I : CLDXCJoinedOrSeparate<"I">, HelpText<"Add directory to include search path">, MetaVarName<"">, Alias; def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, @@ -6820,6 +6830,8 @@ Group, Flags<[DXCOption, NoXarchOption]>; class DXCJoinedOrSeparate : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>; +class DXCJoinedOrSeparateConflict : Option<["--", "/", "-"], name, + KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>; def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>, Group, Flags<[DXCOption, NoXarchOption]>, Alias, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6225,6 +6225,7 @@ if (IsClCompatMode) { // Include CL and Core options. IncludedFlagsBitmask |= options::CLOption; + IncludedFlagsBitmask |= options::CLDXCOption; IncludedFlagsBitmask |= options::CoreOption; } else { ExcludedFlagsBitmask |= options::CLOption; @@ -6232,6 +6233,7 @@ if (IsDXCMode()) { // Include DXC and Core options. IncludedFlagsBitmask |= options::DXCOption; + IncludedFlagsBitmask |= options::CLDXCOption; IncludedFlagsBitmask |= options::CoreOption; } else { ExcludedFlagsBitmask |= options::DXCOption; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3481,6 +3481,7 @@ types::ID InputType) { const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version, options::OPT_D, + options::OPT_I, options::OPT_S, options::OPT_emit_llvm, options::OPT_disable_llvm_passes, diff --git a/clang/test/Driver/dxc_I.hlsl b/clang/test/Driver/dxc_I.hlsl new file mode 100644 --- /dev/null +++ b/clang/test/Driver/dxc_I.hlsl @@ -0,0 +1,4 @@ +// RUN: %clang_dxc -I test -### %s 2>&1 | FileCheck %s + +// Make sure -I send to cc1. +// CHECK:"-I" "test"