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 @@ -237,14 +237,8 @@ llvm::opt::InputArgList ArgList; ArgList = OptTable.ParseArgs( llvm::ArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount, - /*FlagsToInclude=*/ - IsCLMode ? (driver::options::CLOption | driver::options::CoreOption | - driver::options::CLDXCOption) - : /*everything*/ 0, - /*FlagsToExclude=*/driver::options::NoDriverOption | - (IsCLMode - ? 0 - : (driver::options::CLOption | driver::options::CLDXCOption))); + llvm::opt::Visibility(IsCLMode ? driver::options::CLOption + : driver::options::ClangOption)); llvm::SmallVector IndicesToDrop; // Having multiple architecture options (e.g. when building fat binaries) @@ -441,23 +435,13 @@ // Returns the set of DriverModes where an option may be used. unsigned char getModes(const llvm::opt::Option &Opt) { - // Why is this so complicated?! - // Reference is clang::driver::Driver::getIncludeExcludeOptionFlagMasks() unsigned char Result = DM_None; - if (Opt.hasFlag(driver::options::CC1Option)) + if (Opt.hasVisibilityFlag(driver::options::ClangOption)) + Result |= DM_GCC; + if (Opt.hasVisibilityFlag(driver::options::CC1Option)) Result |= DM_CC1; - 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)) { - Result |= DM_CL; - } - } - } + if (Opt.hasVisibilityFlag(driver::options::CLOption)) + Result |= DM_CL; return Result; } diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp --- a/clang-tools-extra/modularize/Modularize.cpp +++ b/clang-tools-extra/modularize/Modularize.cpp @@ -336,13 +336,13 @@ // Helper function for finding the input file in an arguments list. static std::string findInputFile(const CommandLineArguments &CLArgs) { - const unsigned IncludedFlagsBitmask = options::CC1Option; + llvm::opt::Visibility VisibilityMask(options::CC1Option); unsigned MissingArgIndex, MissingArgCount; SmallVector Argv; for (auto I = CLArgs.begin(), E = CLArgs.end(); I != E; ++I) Argv.push_back(I->c_str()); InputArgList Args = getDriverOptTable().ParseArgs( - Argv, MissingArgIndex, MissingArgCount, IncludedFlagsBitmask); + Argv, MissingArgIndex, MissingArgCount, VisibilityMask); std::vector Inputs = Args.getAllArgValues(OPT_INPUT); return ModularizeUtilities::getCanonicalPath(Inputs.back()); } diff --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst --- a/clang/docs/InternalsManual.rst +++ b/clang/docs/InternalsManual.rst @@ -663,9 +663,11 @@ * ``HelpText`` holds the text that will be printed besides the option name when the user requests help (e.g. via ``clang --help``). * ``Group`` specifies the "category" of options this option belongs to. This is - used by various tools to filter certain options of interest. -* ``Flags`` may contain a number of "tags" associated with the option. This - enables more granular filtering than the ``Group`` attribute. + used by various tools to categorize and sometimes filter options. +* ``Flags`` may contain "tags" associated with the option. These may affect how + the option is rendered, or if it's hidden in some contexts. +* ``Visibility`` should be used to specify the drivers in which a particular + option would be available. This attribute will impact tool --help * ``Alias`` denotes that the option is an alias of another option. This may be combined with ``AliasArgs`` that holds the implied value. @@ -674,12 +676,14 @@ // Options.td def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, - + Group, Flags<[CC1Option]>, + + Group, Visibility<[ClangOption, CC1Option]>, + HelpText<"Load pass plugin from a dynamic shared object file.">; -New options are recognized by the Clang driver unless marked with the -``NoDriverOption`` flag. On the other hand, options intended for the ``-cc1`` -frontend must be explicitly marked with the ``CC1Option`` flag. +New options are recognized by the ``clang`` driver mode if ``Visibility`` is +not specified or contains ``ClangOption``. Options intended for ``clang -cc1`` +must be explicitly marked with the ``CC1Option`` flag. Flags that specify +``CC1Option`` but not ``ClangOption`` will only be accessible via ``-cc1``. +This is similar for other driver modes, such as ``clang-cl`` or ``flang``. Next, parse (or manufacture) the command line arguments in the Clang driver and use them to construct the ``-cc1`` job: @@ -874,7 +878,8 @@ .. code-block:: text - def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Flags<[CC1Option]>, + def fignore_exceptions : Flag<["-"], "fignore-exceptions">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoFlag>; **Negative Flag** @@ -884,7 +889,8 @@ .. code-block:: text - def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Flags<[CC1Option]>, + def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoNegativeFlag>; **Negative and Positive Flag** @@ -898,9 +904,9 @@ defm legacy_pass_manager : BoolOption<"f", "legacy-pass-manager", CodeGenOpts<"LegacyPassManager">, DefaultFalse, - PosFlag, - NegFlag, - BothFlags<[CC1Option]>>; + PosFlag, + NegFlag, + BothFlags<[], [ClangOption, CC1Option]>>; With most such pair of flags, the ``-cc1`` frontend accepts only the flag that changes the default key path value. The Clang driver is responsible for @@ -912,10 +918,11 @@ ``flegacy-pass-manager`` and the negative ``fno-legacy-pass-manager``. ``BoolOption`` also implies the ``-`` prefix for both flags. It's also possible to use ``BoolFOption`` that implies the ``"f"`` prefix and ``Group``. -The ``PosFlag`` and ``NegFlag`` classes hold the associated boolean value, an -array of elements passed to the ``Flag`` class and the help text. The optional -``BothFlags`` class holds an array of ``Flag`` elements that are common for both -the positive and negative flag and their common help text suffix. +The ``PosFlag`` and ``NegFlag`` classes hold the associated boolean value, +arrays of elements passed to the ``Flag`` and ``Visibility`` classes and the +help text. The optional ``BothFlags`` class holds arrays of ``Flag`` and +``Visibility`` elements that are common for both the positive and negative flag +and their common help text suffix. **String** @@ -924,7 +931,8 @@ .. code-block:: text - def isysroot : JoinedOrSeparate<["-"], "isysroot">, Flags<[CC1Option]>, + def isysroot : JoinedOrSeparate<["-"], "isysroot">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoString, [{"/"}]>; **List of Strings** @@ -935,7 +943,8 @@ .. code-block:: text - def frewrite_map_file : Separate<["-"], "frewrite-map-file">, Flags<[CC1Option]>, + def frewrite_map_file : Separate<["-"], "frewrite-map-file">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoStringVector>; **Integer** @@ -946,7 +955,8 @@ .. code-block:: text - def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Flags<[CC1Option]>, + def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoInt, "4096">; **Enumeration** @@ -963,7 +973,8 @@ .. code-block:: text - def mthread_model : Separate<["-"], "mthread-model">, Flags<[CC1Option]>, + def mthread_model : Separate<["-"], "mthread-model">, + Visibility<[ClangOption, CC1Option]>, Values<"posix,single">, NormalizedValues<["POSIX", "Single"]>, NormalizedValuesScope<"LangOptions::ThreadModelKind">, MarshallingInfoEnum, "POSIX">; @@ -983,7 +994,8 @@ .. code-block:: text - def fms_extensions : Flag<["-"], "fms-extensions">, Flags<[CC1Option]>, + def fms_extensions : Flag<["-"], "fms-extensions">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoFlag>, ImpliedByAnyOf<[fms_compatibility.KeyPath], "true">; @@ -994,7 +1006,8 @@ .. code-block:: text - def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, Flags<[CC1Option]>, + def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoFlag>, ShouldParseIf; diff --git a/clang/include/clang/Driver/ClangOptionDocs.td b/clang/include/clang/Driver/ClangOptionDocs.td --- a/clang/include/clang/Driver/ClangOptionDocs.td +++ b/clang/include/clang/Driver/ClangOptionDocs.td @@ -28,8 +28,10 @@ }]; string Program = "clang"; - list ExcludedFlags = ["HelpHidden", "NoDriverOption", - "CLOption", "Unsupported", "Ignored", "FlangOnlyOption"]; + // Note: We *must* use DefaultVis and not ClangOption, since that's + // the name of the actual TableGen record. The alias will not work. + list VisibilityMask = ["DefaultVis"]; + list IgnoreFlags = ["HelpHidden", "Unsupported", "Ignored"]; } include "Options.td" diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -455,7 +455,7 @@ /// ParseArgStrings - Parse the given list of strings into an /// ArgList. llvm::opt::InputArgList ParseArgStrings(ArrayRef Args, - bool IsClCompatMode, + bool UseDriverMode, bool &ContainsError); /// BuildInputs - Construct the list of inputs and their types from @@ -759,7 +759,8 @@ /// Get bitmasks for which option flags to include and exclude based on /// the driver mode. - std::pair getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const; + llvm::opt::Visibility + getOptionVisibilityMask(bool UseDriverMode = true) const; /// Helper used in BuildJobsForAction. Doesn't use the cache when building /// jobs specifically for the given action, but will use the cache when 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 @@ -23,19 +23,9 @@ LinkerInput = (1 << 5), NoArgumentUnused = (1 << 6), Unsupported = (1 << 7), - CoreOption = (1 << 8), - CLOption = (1 << 9), - CC1Option = (1 << 10), - CC1AsOption = (1 << 11), - NoDriverOption = (1 << 12), - LinkOption = (1 << 13), - FlangOption = (1 << 14), - FC1Option = (1 << 15), - FlangOnlyOption = (1 << 16), - DXCOption = (1 << 17), - CLDXCOption = (1 << 18), - Ignored = (1 << 19), - TargetSpecific = (1 << 20), + LinkOption = (1 << 8), + Ignored = (1 << 9), + TargetSpecific = (1 << 10), }; // Flags specifically for clang option visibility. We alias DefaultVis to @@ -43,6 +33,12 @@ // for multiple drivers (clang, cl, flang, etc). enum ClangVisibility { ClangOption = llvm::opt::DefaultVis, + CLOption = (1 << 1), + CC1Option = (1 << 2), + CC1AsOption = (1 << 3), + FlangOption = (1 << 4), + FC1Option = (1 << 5), + DXCOption = (1 << 6), }; 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 @@ -35,46 +35,10 @@ // Ignored - The option is unsupported, and the driver will silently ignore it. def Ignored : OptionFlag; -// CoreOption - This is considered a "core" Clang option, available in both -// clang and clang-cl modes. -def CoreOption : OptionFlag; - -// CLOption - This is a cl.exe compatibility option. Options with this flag -// are made available when the driver is running in CL compatibility mode. -def CLOption : OptionFlag; - -// CC1Option - This option should be accepted by clang -cc1. -def CC1Option : OptionFlag; - -// CC1AsOption - This option should be accepted by clang -cc1as. -def CC1AsOption : OptionFlag; - -// DXCOption - This is a dxc.exe compatibility option. Options with this flag -// 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; - // If an option affects linking, but has a primary group (so Link_Group cannot // be used), add this flag. def LinkOption : OptionFlag; -// FlangOption - This is considered a "core" Flang option, available in -// flang mode. -def FlangOption : OptionFlag; - -// FlangOnlyOption - This option should only be used by Flang (i.e. it is not -// available for Clang) -def FlangOnlyOption : OptionFlag; - -// FC1Option - This option should be accepted by flang -fc1. -def FC1Option : OptionFlag; - // This is a target-specific option for compilation. Using it on an unsupported // target will lead to an err_drv_unsupported_opt_for_target error. def TargetSpecific : OptionFlag; @@ -93,6 +57,27 @@ // opposed to clang -cc1, the CL driver, or the flang driver). defvar ClangOption = DefaultVis; +// CLOption - This is a cl.exe compatibility option. Options with this flag +// are made available when the driver is running in CL compatibility mode. +def CLOption : OptionVisibility; + +// CC1Option - This option should be accepted by clang -cc1. +def CC1Option : OptionVisibility; + +// CC1AsOption - This option should be accepted by clang -cc1as. +def CC1AsOption : OptionVisibility; + +// FlangOption - This is considered a "core" Flang option, available in +// flang mode. +def FlangOption : OptionVisibility; + +// FC1Option - This option should be accepted by flang -fc1. +def FC1Option : OptionVisibility; + +// DXCOption - This is a dxc.exe compatibility option. Options with this flag +// are made available when the driver is running in DXC compatibility mode. +def DXCOption : OptionVisibility; + ///////// // Docs @@ -210,7 +195,9 @@ def m_wasm_Features_Driver_Group : OptionGroup<"">, Group, DocName<"WebAssembly Driver">; def m_x86_Features_Group : OptionGroup<"">, - Group, Flags<[CoreOption]>, DocName<"X86">; + Group, + Visibility<[ClangOption, CLOption, DXCOption]>, + DocName<"X86">; def m_riscv_Features_Group : OptionGroup<"">, Group, DocName<"RISC-V">; @@ -264,7 +251,7 @@ // Unsupported flang groups def flang_ignored_w_Group : OptionGroup<"">, - Group, Flags<[FlangOnlyOption, Ignored]>; + Group, Flags<[Ignored]>, Visibility<[FlangOption]>; // Group for clang options in the process of deprecation. // Please include the version that deprecated the flag as comment to allow @@ -287,7 +274,8 @@ // Retired with clang-16.0, to provide a deprecation period; it should // be removed in Clang 18 or later. def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">, - Flags<[CC1Option, CoreOption, NoArgumentUnused]>, + Flags<[NoArgumentUnused]>, + Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, Group; // Group that ignores all gcc optimizations that won't be implemented @@ -324,10 +312,11 @@ // This is useful if the option is usually disabled. // Use this only when the option cannot be declared via BoolFOption. multiclass OptInCC1FFlag flags=[]> { - def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>, + string help="", + list vis=[ClangOption]> { + def f#NAME : Flag<["-"], "f"#name>, Visibility<[CC1Option] # vis>, Group, HelpText; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, + def fno_#NAME : Flag<["-"], "fno-"#name>, Visibility, Group, HelpText; } @@ -335,10 +324,11 @@ // Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. // Use this only when the option cannot be declared via BoolFOption. multiclass OptOutCC1FFlag flags=[]> { - def f#NAME : Flag<["-"], "f"#name>, Flags, + string help="", + list vis=[ClangOption]> { + def f#NAME : Flag<["-"], "f"#name>, Visibility, Group, HelpText; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>, + def fno_#NAME : Flag<["-"], "fno-"#name>, Visibility<[CC1Option] # vis>, Group, HelpText; } @@ -346,20 +336,22 @@ // Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled. // This is useful if the option is usually disabled. multiclass OptInFC1FFlag flags=[]> { - def f#NAME : Flag<["-"], "f"#name>, Flags<[FC1Option] # flags>, + string help="", + list vis=[ClangOption]> { + def f#NAME : Flag<["-"], "f"#name>, Visibility<[FC1Option] # vis>, Group, HelpText; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, + def fno_#NAME : Flag<["-"], "fno-"#name>, Visibility, Group, HelpText; } // A boolean option which is opt-out in FC1. The negative option exists in FC1 and // Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. multiclass OptOutFC1FFlag flags=[]> { - def f#NAME : Flag<["-"], "f"#name>, Flags, + string help="", + list vis=[ClangOption]> { + def f#NAME : Flag<["-"], "f"#name>, Visibility, Group, HelpText; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[FC1Option] # flags>, + def fno_#NAME : Flag<["-"], "fno-"#name>, Visibility<[FC1Option] # vis>, Group, HelpText; } @@ -613,7 +605,8 @@ // Developer Driver Options -def internal_Group : OptionGroup<"">, Flags<[HelpHidden]>; +def internal_Group : OptionGroup<"">, + Flags<[HelpHidden]>; def internal_driver_Group : OptionGroup<"">, Group, HelpText<"DRIVER OPTIONS">; def internal_debug_Group : @@ -623,17 +616,20 @@ class InternalDriverOpt : Group, Flags<[NoXarchOption, HelpHidden]>; def driver_mode : Joined<["--"], "driver-mode=">, Group, - Flags<[CoreOption, NoXarchOption, HelpHidden]>, + Flags<[NoXarchOption, HelpHidden]>, + Visibility<[ClangOption, CLOption, DXCOption]>, HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">; def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group, - Flags<[CoreOption, NoXarchOption, HelpHidden]>, + Flags<[NoXarchOption, HelpHidden]>, + Visibility<[ClangOption, CLOption, DXCOption]>, HelpText<"Set the rsp quoting to either 'posix', or 'windows'">; def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt, HelpText<"Name for native GCC compiler">, MetaVarName<"">; class InternalDebugOpt : Group, - Flags<[NoXarchOption, HelpHidden, CoreOption]>; + Flags<[NoXarchOption, HelpHidden]>, + Visibility<[ClangOption, CLOption, DXCOption]>; def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt, HelpText<"Simulate installation in the given directory">; def ccc_print_phases : Flag<["-"], "ccc-print-phases">, InternalDebugOpt, @@ -648,12 +644,15 @@ def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt, HelpText<"Apply modifications and produces temporary files that conform to ARC">; def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">, - HelpText<"Output path for the plist report">, Flags<[CC1Option]>, + HelpText<"Output path for the plist report">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoString>; def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">, - HelpText<"Emit ARC errors even if the migrator can fix them">, Flags<[CC1Option]>, + HelpText<"Emit ARC errors even if the migrator can fix them">, + Visibility<[ClangOption, CC1Option]>, MarshallingInfoFlag>; -def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, Flags<[NoArgumentUnused, CoreOption]>, +def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, + Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CLOption, DXCOption]>, HelpText<"Emit reproducer on (option: off, crash (default), error, always)">; def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt, Alias, AliasArgs<["always"]>, @@ -661,9 +660,10 @@ def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, InternalDebugOpt, HelpText<"Emit a compilation database fragment to the specified directory">; -def round_trip_args : Flag<["-"], "round-trip-args">, Flags<[CC1Option, NoDriverOption]>, +def round_trip_args : Flag<["-"], "round-trip-args">, Visibility<[CC1Option]>, HelpText<"Enable command line arguments round-trip.">; -def no_round_trip_args : Flag<["-"], "no-round-trip-args">, Flags<[CC1Option, NoDriverOption]>, +def no_round_trip_args : Flag<["-"], "no-round-trip-args">, + Visibility<[CC1Option]>, HelpText<"Disable command line arguments round-trip.">; def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>, @@ -673,60 +673,78 @@ HelpText<"Apply modifications and produces temporary files to migrate to " "modern ObjC syntax">; -def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, Flags<[CC1Option]>, +def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC literals">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_Literals">; -def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, Flags<[CC1Option]>, +def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC subscripting">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_Subscripting">; -def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, Flags<[CC1Option]>, +def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC property">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_Property">; -def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, Flags<[CC1Option]>, +def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_MigrateDecls">; -def objcmt_migrate_readonly_property : Flag<["-"], "objcmt-migrate-readonly-property">, Flags<[CC1Option]>, +def objcmt_migrate_readonly_property : Flag<["-"], "objcmt-migrate-readonly-property">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC readonly property">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_ReadonlyProperty">; -def objcmt_migrate_readwrite_property : Flag<["-"], "objcmt-migrate-readwrite-property">, Flags<[CC1Option]>, +def objcmt_migrate_readwrite_property : Flag<["-"], "objcmt-migrate-readwrite-property">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to modern ObjC readwrite property">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_ReadwriteProperty">; -def objcmt_migrate_property_dot_syntax : Flag<["-"], "objcmt-migrate-property-dot-syntax">, Flags<[CC1Option]>, +def objcmt_migrate_property_dot_syntax : Flag<["-"], "objcmt-migrate-property-dot-syntax">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration of setter/getter messages to property-dot syntax">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_PropertyDotSyntax">; -def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, Flags<[CC1Option]>, +def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to property and method annotations">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_Annotation">; -def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, Flags<[CC1Option]>, +def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to infer instancetype for method result type">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_Instancetype">; -def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, Flags<[CC1Option]>, +def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_NsMacros">; -def objcmt_migrate_protocol_conformance : Flag<["-"], "objcmt-migrate-protocol-conformance">, Flags<[CC1Option]>, +def objcmt_migrate_protocol_conformance : Flag<["-"], "objcmt-migrate-protocol-conformance">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to add protocol conformance on classes">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_ProtocolConformance">; -def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">, Flags<[CC1Option]>, +def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Make migration to 'atomic' properties">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_AtomicProperty">; -def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">, Flags<[CC1Option]>, +def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_ReturnsInnerPointerProperty">; -def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">, Flags<[CC1Option]>, +def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty">; -def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init">, Flags<[CC1Option]>, +def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_DesignatedInitializer">; -def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">, Flags<[CC1Option]>, +def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Only modify files with a filename contained in the provided directory path">, MarshallingInfoString>; -def : Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, +def : Joined<["-"], "objcmt-whitelist-dir-path=">, + Visibility<[ClangOption, CC1Option]>, HelpText<"Alias for -objcmt-allowlist-dir-path">, Alias; // The misspelt "white-list" [sic] alias is due for removal. -def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>, +def : Joined<["-"], "objcmt-white-list-dir-path=">, + Visibility<[ClangOption, CC1Option]>, Alias; // Make sure all other -ccc- options are rejected. @@ -734,11 +752,13 @@ // Standard Options -def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption, FlangOption]>, +def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption]>, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, HelpText<"Print (but do not run) the commands to run for this compilation">; def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>, - Flags<[NoXarchOption, CoreOption]>; -def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, Group; + Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>; +def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, + Group; def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">, HelpText<"Search $prefix$file for executables, libraries, and data files. " "If $prefix is a directory, search $prefix/$file">; @@ -748,28 +768,38 @@ def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>, HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. " "Clang will use the GCC installation with the largest version">; -def CC : Flag<["-"], "CC">, Flags<[CC1Option]>, Group, +def CC : Flag<["-"], "CC">, Visibility<[ClangOption, CC1Option]>, + Group, HelpText<"Include comments from within macros in preprocessed output">, MarshallingInfoFlag>; -def C : Flag<["-"], "C">, Flags<[CC1Option]>, Group, +def C : Flag<["-"], "C">, Visibility<[ClangOption, CC1Option]>, + Group, HelpText<"Include comments in preprocessed output">, MarshallingInfoFlag>; def D : JoinedOrSeparate<["-"], "D">, Group, - Flags<[CC1Option, FlangOption, FC1Option]>, MetaVarName<"=">, + Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, + MetaVarName<"=">, HelpText<"Define to (or 1 if omitted)">; -def E : Flag<["-"], "E">, Flags<[NoXarchOption,CC1Option, FlangOption, FC1Option]>, Group, +def E : Flag<["-"], "E">, Flags<[NoXarchOption]>, + Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, + Group, HelpText<"Only run the preprocessor">; -def F : JoinedOrSeparate<["-"], "F">, Flags<[RenderJoined,CC1Option]>, +def F : JoinedOrSeparate<["-"], "F">, Flags<[RenderJoined]>, + Visibility<[ClangOption, CC1Option]>, HelpText<"Add directory to framework include search path">; -def G : JoinedOrSeparate<["-"], "G">, Flags<[NoXarchOption,TargetSpecific]>, Group, +def G : JoinedOrSeparate<["-"], "G">, Flags<[NoXarchOption, TargetSpecific]>, + Group, MetaVarName<"">, HelpText<"Put objects of at most bytes " "into small data section (MIPS / Hexagon)">; -def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, Alias; -def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group, +def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, + Group, Alias; +def H : Flag<["-"], "H">, Visibility<[ClangOption, CC1Option]>, + Group, HelpText<"Show header includes and nesting depth">, MarshallingInfoFlag>; def fshow_skipped_includes : Flag<["-"], "fshow-skipped-includes">, - Flags<[CC1Option]>, HelpText<"Show skipped includes in -H output.">, + Visibility<[ClangOption, CC1Option]>, + HelpText<"Show skipped includes in -H output.">, DocBrief<[{#include files may be "skipped" due to include guard optimization or #pragma once. This flag makes -H show also such includes.}]>, MarshallingInfoFlag>; @@ -778,7 +808,8 @@ HelpText<"Restrict all prior -I flags to double-quoted inclusion and " "remove current directory from include path">; def I : JoinedOrSeparate<["-"], "I">, Group, - Flags<[CC1Option,CC1AsOption,FlangOption,FC1Option]>, MetaVarName<"">, + Visibility<[ClangOption, CC1Option, CC1AsOption, FlangOption, FC1Option]>, + MetaVarName<"">, HelpText<"Add directory to the end of the list of include search paths">, DocBrief<[{Add directory to include search path. For C++ inputs, if there are multiple -I options, these directories are searched @@ -799,86 +830,111 @@ def MF : JoinedOrSeparate<["-"], "MF">, Group, HelpText<"Write depfile output from -MMD, -MD, -MM, or -M to ">, MetaVarName<"">; -def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>, +def MG : Flag<["-"], "MG">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Add missing headers to depfile">, MarshallingInfoFlag>; def MJ : JoinedOrSeparate<["-"], "MJ">, Group, HelpText<"Write a compilation database entry per input">; -def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>, +def MP : Flag<["-"], "MP">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Create phony target for each dependency (other than main file)">, MarshallingInfoFlag>; -def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>, +def MQ : JoinedOrSeparate<["-"], "MQ">, Group, + Visibility<[ClangOption, CC1Option]>, HelpText<"Specify name of main file output to quote in depfile">; -def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>, +def MT : JoinedOrSeparate<["-"], "MT">, Group, + Visibility<[ClangOption, CC1Option]>, HelpText<"Specify name of main file output in depfile">, MarshallingInfoStringVector>; -def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>, +def MV : Flag<["-"], "MV">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Use NMake/Jom format for the depfile">, MarshallingInfoFlag, "DependencyOutputFormat::Make">, Normalizer<"makeFlagToValueNormalizer(DependencyOutputFormat::NMake)">; def Mach : Flag<["-"], "Mach">, Group; -def O0 : Flag<["-"], "O0">, Group, Flags<[CC1Option, FC1Option, HelpHidden]>; -def O4 : Flag<["-"], "O4">, Group, Flags<[CC1Option, FC1Option, HelpHidden]>; +def O0 : Flag<["-"], "O0">, Group, Flags<[HelpHidden]>, + Visibility<[ClangOption, CC1Option, FC1Option]>; +def O4 : Flag<["-"], "O4">, Group, Flags<[HelpHidden]>, + Visibility<[ClangOption, CC1Option, FC1Option]>; def ObjCXX : Flag<["-"], "ObjC++">, Flags<[NoXarchOption]>, HelpText<"Treat source input files as Objective-C++ inputs">; def ObjC : Flag<["-"], "ObjC">, Flags<[NoXarchOption]>, HelpText<"Treat source input files as Objective-C inputs">; -def O : Joined<["-"], "O">, Group, Flags<[CC1Option,FC1Option]>; -def O_flag : Flag<["-"], "O">, Flags<[CC1Option,FC1Option]>, Alias, AliasArgs<["1"]>; -def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option, FlangOption]>; -def P : Flag<["-"], "P">, Flags<[CC1Option,FlangOption,FC1Option]>, Group, +def O : Joined<["-"], "O">, Group, + Visibility<[ClangOption, CC1Option, FC1Option]>; +def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>, + Alias, AliasArgs<["1"]>; +def Ofast : Joined<["-"], "Ofast">, Group, + Visibility<[ClangOption, CC1Option, FlangOption]>; +def P : Flag<["-"], "P">, + Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, + Group, HelpText<"Disable linemarker output in -E mode">, MarshallingInfoNegativeFlag>; -def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, +def Qy : Flag<["-"], "Qy">, Visibility<[ClangOption, CC1Option]>, HelpText<"Emit metadata containing compiler name and version">; -def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, +def Qn : Flag<["-"], "Qn">, Visibility<[ClangOption, CC1Option]>, HelpText<"Do not emit metadata containing compiler name and version">; def : Flag<["-"], "fident">, Group, Alias, - Flags<[CoreOption, CC1Option]>; + Visibility<[ClangOption, CLOption, DXCOption, CC1Option]>; def : Flag<["-"], "fno-ident">, Group, Alias, - Flags<[CoreOption, CC1Option]>; -def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[NoXarchOption, CoreOption]>, + Visibility<[ClangOption, CLOption, DXCOption, CC1Option]>; +def Qunused_arguments : Flag<["-"], "Qunused-arguments">, + Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; -def S : Flag<["-"], "S">, Flags<[NoXarchOption,CC1Option,FlangOption,FC1Option]>, Group, +def S : Flag<["-"], "S">, Flags<[NoXarchOption]>, + Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, + Group, HelpText<"Only run preprocess and compilation steps">; def T : JoinedOrSeparate<["-"], "T">, Group, MetaVarName<"