@@ -663,9 +663,11 @@ Then, specify additional attributes via mix-ins:
663
663
* ``HelpText `` holds the text that will be printed besides the option name when
664
664
the user requests help (e.g. via ``clang --help ``).
665
665
* ``Group `` specifies the "category" of options this option belongs to. This is
666
- used by various tools to filter certain options of interest.
667
- * ``Flags `` may contain a number of "tags" associated with the option. This
668
- enables more granular filtering than the ``Group `` attribute.
666
+ used by various tools to categorize and sometimes filter options.
667
+ * ``Flags `` may contain "tags" associated with the option. These may affect how
668
+ the option is rendered, or if it's hidden in some contexts.
669
+ * ``Visibility `` should be used to specify the drivers in which a particular
670
+ option would be available. This attribute will impact tool --help
669
671
* ``Alias `` denotes that the option is an alias of another option. This may be
670
672
combined with ``AliasArgs `` that holds the implied value.
671
673
@@ -674,12 +676,14 @@ Then, specify additional attributes via mix-ins:
674
676
// Options.td
675
677
676
678
def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
677
- + Group<f_Group>, Flags<[ CC1Option]>,
679
+ + Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
678
680
+ HelpText<"Load pass plugin from a dynamic shared object file.">;
679
681
680
- New options are recognized by the Clang driver unless marked with the
681
- ``NoDriverOption `` flag. On the other hand, options intended for the ``-cc1 ``
682
- frontend must be explicitly marked with the ``CC1Option `` flag.
682
+ New options are recognized by the ``clang `` driver mode if ``Visibility `` is
683
+ not specified or contains ``ClangOption ``. Options intended for ``clang -cc1 ``
684
+ must be explicitly marked with the ``CC1Option `` flag. Flags that specify
685
+ ``CC1Option `` but not ``ClangOption `` will only be accessible via ``-cc1 ``.
686
+ This is similar for other driver modes, such as ``clang-cl `` or ``flang ``.
683
687
684
688
Next, parse (or manufacture) the command line arguments in the Clang driver and
685
689
use them to construct the ``-cc1 `` job:
@@ -874,7 +878,8 @@ present on command line.
874
878
875
879
.. code-block :: text
876
880
877
- def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Flags<[CC1Option]>,
881
+ def fignore_exceptions : Flag<["-"], "fignore-exceptions">,
882
+ Visibility<[ClangOption, CC1Option]>,
878
883
MarshallingInfoFlag<LangOpts<"IgnoreExceptions">>;
879
884
880
885
**Negative Flag **
@@ -884,7 +889,8 @@ present on command line.
884
889
885
890
.. code-block :: text
886
891
887
- def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Flags<[CC1Option]>,
892
+ def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">,
893
+ Visibility<[ClangOption, CC1Option]>,
888
894
MarshallingInfoNegativeFlag<CodeGenOpts<"AsmVerbose">>;
889
895
890
896
**Negative and Positive Flag **
@@ -898,9 +904,9 @@ line.
898
904
899
905
defm legacy_pass_manager : BoolOption<"f", "legacy-pass-manager",
900
906
CodeGenOpts<"LegacyPassManager">, DefaultFalse,
901
- PosFlag<SetTrue, [], "Use the legacy pass manager in LLVM">,
902
- NegFlag<SetFalse, [], "Use the new pass manager in LLVM">,
903
- BothFlags<[CC1Option]>>;
907
+ PosFlag<SetTrue, [], [], "Use the legacy pass manager in LLVM">,
908
+ NegFlag<SetFalse, [], [], "Use the new pass manager in LLVM">,
909
+ BothFlags<[], [ClangOption, CC1Option]>>;
904
910
905
911
With most such pair of flags, the ``-cc1 `` frontend accepts only the flag that
906
912
changes the default key path value. The Clang driver is responsible for
@@ -912,10 +918,11 @@ full names of both flags. The positive flag would then be named
912
918
``flegacy-pass-manager `` and the negative ``fno-legacy-pass-manager ``.
913
919
``BoolOption `` also implies the ``- `` prefix for both flags. It's also possible
914
920
to use ``BoolFOption `` that implies the ``"f" `` prefix and ``Group<f_Group> ``.
915
- The ``PosFlag `` and ``NegFlag `` classes hold the associated boolean value, an
916
- array of elements passed to the ``Flag `` class and the help text. The optional
917
- ``BothFlags `` class holds an array of ``Flag `` elements that are common for both
918
- the positive and negative flag and their common help text suffix.
921
+ The ``PosFlag `` and ``NegFlag `` classes hold the associated boolean value,
922
+ arrays of elements passed to the ``Flag `` and ``Visibility `` classes and the
923
+ help text. The optional ``BothFlags `` class holds arrays of ``Flag `` and
924
+ ``Visibility `` elements that are common for both the positive and negative flag
925
+ and their common help text suffix.
919
926
920
927
**String **
921
928
@@ -924,7 +931,8 @@ the option appears on the command line, the argument value is simply copied.
924
931
925
932
.. code-block :: text
926
933
927
- def isysroot : JoinedOrSeparate<["-"], "isysroot">, Flags<[CC1Option]>,
934
+ def isysroot : JoinedOrSeparate<["-"], "isysroot">,
935
+ Visibility<[ClangOption, CC1Option]>,
928
936
MarshallingInfoString<HeaderSearchOpts<"Sysroot">, [{"/"}]>;
929
937
930
938
**List of Strings **
@@ -935,7 +943,8 @@ vector.
935
943
936
944
.. code-block :: text
937
945
938
- def frewrite_map_file : Separate<["-"], "frewrite-map-file">, Flags<[CC1Option]>,
946
+ def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
947
+ Visibility<[ClangOption, CC1Option]>,
939
948
MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>;
940
949
941
950
**Integer **
@@ -946,7 +955,8 @@ and the result is assigned to the key path on success.
946
955
947
956
.. code-block :: text
948
957
949
- def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Flags<[CC1Option]>,
958
+ def mstack_probe_size : Joined<["-"], "mstack-probe-size=">,
959
+ Visibility<[ClangOption, CC1Option]>,
950
960
MarshallingInfoInt<CodeGenOpts<"StackProbeSize">, "4096">;
951
961
952
962
**Enumeration **
@@ -963,7 +973,8 @@ comma-separated string values and elements of the array within
963
973
964
974
.. code-block :: text
965
975
966
- def mthread_model : Separate<["-"], "mthread-model">, Flags<[CC1Option]>,
976
+ def mthread_model : Separate<["-"], "mthread-model">,
977
+ Visibility<[ClangOption, CC1Option]>,
967
978
Values<"posix,single">, NormalizedValues<["POSIX", "Single"]>,
968
979
NormalizedValuesScope<"LangOptions::ThreadModelKind">,
969
980
MarshallingInfoEnum<LangOpts<"ThreadModel">, "POSIX">;
@@ -983,7 +994,8 @@ Finally, the command line is parsed according to the primary annotation.
983
994
984
995
.. code-block :: text
985
996
986
- def fms_extensions : Flag<["-"], "fms-extensions">, Flags<[CC1Option]>,
997
+ def fms_extensions : Flag<["-"], "fms-extensions">,
998
+ Visibility<[ClangOption, CC1Option]>,
987
999
MarshallingInfoFlag<LangOpts<"MicrosoftExt">>,
988
1000
ImpliedByAnyOf<[fms_compatibility.KeyPath], "true">;
989
1001
@@ -994,7 +1006,8 @@ true.
994
1006
995
1007
.. code-block :: text
996
1008
997
- def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, Flags<[CC1Option]>,
1009
+ def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">,
1010
+ Visibility<[ClangOption, CC1Option]>,
998
1011
MarshallingInfoFlag<LangOpts<"OpenMPIRBuilder">>,
999
1012
ShouldParseIf<fopenmp.KeyPath>;
1000
1013
0 commit comments