diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -238,13 +238,10 @@ ArgList = OptTable.ParseArgs( llvm::ArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount, /*FlagsToInclude=*/ - IsCLMode ? (driver::options::CLOption | driver::options::CoreOption | - driver::options::CLDXCOption) + IsCLMode ? (driver::options::CLOption | driver::options::CoreOption) : /*everything*/ 0, /*FlagsToExclude=*/driver::options::NoDriverOption | - (IsCLMode - ? 0 - : (driver::options::CLOption | driver::options::CLDXCOption))); + (IsCLMode ? 0 : driver::options::CLOption)); llvm::SmallVector IndicesToDrop; // Having multiple architecture options (e.g. when building fat binaries) @@ -449,8 +446,6 @@ if (!Opt.hasFlag(driver::options::NoDriverOption)) { if (Opt.hasFlag(driver::options::CLOption)) { Result |= DM_CL; - } else if (Opt.hasFlag(driver::options::CLDXCOption)) { - Result |= DM_CL; } else { Result |= DM_GCC; if (Opt.hasFlag(driver::options::CoreOption)) { 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,9 +36,8 @@ FC1Option = (1 << 15), FlangOnlyOption = (1 << 16), DXCOption = (1 << 17), - CLDXCOption = (1 << 18), - Ignored = (1 << 19), - TargetSpecific = (1 << 20), + Ignored = (1 << 18), + TargetSpecific = (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,10 +53,6 @@ // 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; @@ -6844,7 +6840,7 @@ // clang-cl Options //===----------------------------------------------------------------------===// -def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>, +def cl_Group : OptionGroup<"">, HelpText<"CL.EXE COMPATIBILITY OPTIONS">; def cl_compile_Group : OptionGroup<"">, @@ -6853,42 +6849,45 @@ def cl_ignored_Group : OptionGroup<"">, Group; -class CLFlag : Option<["/", "-"], name, KIND_FLAG>, - Group, Flags<[CLOption, NoXarchOption]>; - -class CLDXCFlag : Option<["/", "-"], name, KIND_FLAG>, - Group, Flags<[CLDXCOption, NoXarchOption]>; - -class CLCompileFlag : Option<["/", "-"], name, KIND_FLAG>, - Group, Flags<[CLOption, NoXarchOption]>; +class CLFlagOpts flags> + : Flags; -class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>, - Group, Flags<[CLOption, NoXarchOption]>; +class CLFlag flags = [CLOption]> + : Option<["/", "-"], name, KIND_FLAG>, + Group, CLFlagOpts; -class CLJoined : Option<["/", "-"], name, KIND_JOINED>, - Group, Flags<[CLOption, NoXarchOption]>; +class CLCompileFlag flags = [CLOption]> + : Option<["/", "-"], name, KIND_FLAG>, + Group, CLFlagOpts; -class CLDXCJoined : Option<["/", "-"], name, KIND_JOINED>, - Group, Flags<[CLDXCOption, NoXarchOption]>; +class CLIgnoredFlag flags = [CLOption]> + : Option<["/", "-"], name, KIND_FLAG>, + Group, CLFlagOpts; -class CLCompileJoined : Option<["/", "-"], name, KIND_JOINED>, - Group, Flags<[CLOption, NoXarchOption]>; +class CLJoined flags = [CLOption]> + : Option<["/", "-"], name, KIND_JOINED>, + Group, CLFlagOpts; -class CLIgnoredJoined : Option<["/", "-"], name, KIND_JOINED>, - Group, Flags<[CLOption, NoXarchOption, HelpHidden]>; +class CLCompileJoined flags = [CLOption]> + : Option<["/", "-"], name, KIND_JOINED>, + Group, CLFlagOpts; -class CLJoinedOrSeparate : Option<["/", "-"], name, - KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>; +class CLIgnoredJoined flags = [CLOption]> + : Option<["/", "-"], name, KIND_JOINED>, + Group, CLFlagOpts; -class CLDXCJoinedOrSeparate : Option<["/", "-"], name, - KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>; +class CLJoinedOrSeparate flags = [CLOption]> + : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, + Group, CLFlagOpts; -class CLCompileJoinedOrSeparate : Option<["/", "-"], name, - KIND_JOINED_OR_SEPARATE>, Group, - Flags<[CLOption, NoXarchOption]>; +class CLCompileJoinedOrSeparate flags = [CLOption]> + : Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>, + Group, CLFlagOpts; -class CLRemainingArgsJoined : Option<["/", "-"], name, - KIND_REMAINING_ARGS_JOINED>, Group, Flags<[CLOption, NoXarchOption]>; +class CLRemainingArgsJoined flags = [CLOption]> + : Option<["/", "-"], name, KIND_REMAINING_ARGS_JOINED>, + Group, CLFlagOpts; // Aliases: // (We don't put any of these in cl_compile_Group as the options they alias are @@ -6959,7 +6958,7 @@ def _SLASH_HELP : CLFlag<"HELP">, Alias; def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias, HelpText<"Create hotpatchable image">; -def _SLASH_I : CLDXCJoinedOrSeparate<"I">, +def _SLASH_I : CLJoinedOrSeparate<"I", [CLOption, DXCOption]>, HelpText<"Add directory to include search path">, MetaVarName<"">, Alias; def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, @@ -6967,7 +6966,7 @@ // The _SLASH_O option handles all the /O flags, but we also provide separate // aliased options to provide separate help messages. -def _SLASH_O : CLDXCJoined<"O">, +def _SLASH_O : CLJoined<"O", [CLOption, DXCOption]>, HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">, MetaVarName<"">; def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>, @@ -6980,7 +6979,7 @@ HelpText<"Only inline functions explicitly or implicitly marked inline">; def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>, HelpText<"Inline functions as deemed beneficial by the compiler">; -def : CLDXCFlag<"Od">, Alias<_SLASH_O>, AliasArgs<["d"]>, +def : CLFlag<"Od", [CLOption, DXCOption]>, Alias<_SLASH_O>, AliasArgs<["d"]>, HelpText<"Disable optimization">; def : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>, HelpText<"No effect">; 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 @@ -6482,7 +6482,6 @@ if (IsClCompatMode) { // Include CL and Core options. IncludedFlagsBitmask |= options::CLOption; - IncludedFlagsBitmask |= options::CLDXCOption; IncludedFlagsBitmask |= options::CoreOption; } else { ExcludedFlagsBitmask |= options::CLOption; @@ -6490,13 +6489,10 @@ if (IsDXCMode()) { // Include DXC and Core options. IncludedFlagsBitmask |= options::DXCOption; - IncludedFlagsBitmask |= options::CLDXCOption; IncludedFlagsBitmask |= options::CoreOption; } else { ExcludedFlagsBitmask |= options::DXCOption; } - if (!IsClCompatMode && !IsDXCMode()) - ExcludedFlagsBitmask |= options::CLDXCOption; return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); } diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp --- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp +++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp @@ -164,8 +164,8 @@ const unsigned OldPos = Pos; std::unique_ptr Arg(OptTable.ParseOneArg( ArgList, Pos, - /* Include */ ClangCLMode ? CoreOption | CLOption | CLDXCOption : 0, - /* Exclude */ ClangCLMode ? 0 : CLOption | CLDXCOption)); + /* Include */ ClangCLMode ? CoreOption | CLOption : 0, + /* Exclude */ ClangCLMode ? 0 : CLOption)); if (!Arg) continue; diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -421,7 +421,8 @@ if (FlagsToInclude && !Opt.hasFlag(FlagsToInclude)) continue; if (Opt.hasFlag(FlagsToExclude)) - continue; + if (!FlagsToInclude || !Opt.hasFlag(FlagsToInclude)) + continue; // See if this option matches. if (std::unique_ptr A = @@ -650,7 +651,8 @@ if (FlagsToInclude && !(Flags & FlagsToInclude)) continue; if (Flags & FlagsToExclude) - continue; + if (!FlagsToInclude || !(Flags & FlagsToInclude)) + continue; // If an alias doesn't have a help text, show a help text for the aliased // option instead.