serge-sans-paille updated this revision to Diff 418579. serge-sans-paille retitled this revision from "Be more explicit about -fvisibility=<arg> documentation" to "[doc] Rely on tblgen to dump supported options value when generating doc". serge-sans-paille edited the summary of this revision. serge-sans-paille added a comment. Herald added subscribers: llvm-commits, aheejin. Herald added a project: LLVM.
Moved to a generic approach as suggested by reviewer. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122378/new/ https://reviews.llvm.org/D122378 Files: clang/include/clang/Driver/Options.td llvm/utils/TableGen/OptRSTEmitter.cpp
Index: llvm/utils/TableGen/OptRSTEmitter.cpp =================================================================== --- llvm/utils/TableGen/OptRSTEmitter.cpp +++ llvm/utils/TableGen/OptRSTEmitter.cpp @@ -60,18 +60,45 @@ // Print the option name. OS << R->getValueAsString("Name"); + StringRef MetaVarName; // Print the meta-variable. if (!isa<UnsetInit>(R->getValueInit("MetaVarName"))) { + MetaVarName = R->getValueAsString("MetaVarName"); + } else if (!isa<UnsetInit>(R->getValueInit("Values"))) + MetaVarName = "<value>"; + + if (!MetaVarName.empty()) { OS << '='; - OS.write_escaped(R->getValueAsString("MetaVarName")); + OS.write_escaped(MetaVarName); } OS << "\n\n"; + std::string HelpText; // The option help text. if (!isa<UnsetInit>(R->getValueInit("HelpText"))) { + HelpText = R->getValueAsString("HelpText").trim().str(); + if (!HelpText.empty() && HelpText.back() != '.') + HelpText.push_back('.'); + } + + if (!isa<UnsetInit>(R->getValueInit("Values"))) { + SmallVector<StringRef> Values; + SplitString(R->getValueAsString("Values"), Values, ","); + HelpText += (" " + MetaVarName + " can be ").str(); + + if (Values.size() == 1) { + HelpText += ("'" + Values.front() + "'.").str(); + } else { + HelpText += "one of '"; + HelpText += join(Values.begin(), Values.end() - 1, "', '"); + HelpText += ("' or '" + Values.back() + "'.").str(); + } + } + + if (!HelpText.empty()) { OS << ' '; - OS.write_escaped(R->getValueAsString("HelpText")); + OS.write_escaped(HelpText); OS << "\n\n"; } } Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -960,7 +960,7 @@ PosFlag<SetTrue, [CC1Option], "Use 32-bit pointers for accessing const/local/shared address spaces">, NegFlag<SetFalse>>; def fgpu_default_stream_EQ : Joined<["-"], "fgpu-default-stream=">, - HelpText<"Specify default stream. Valid values are 'legacy' and 'per-thread'. The default value is 'legacy'. (HIP only)">, + HelpText<"Specify default stream. The default value is 'legacy'. (HIP only)">, Flags<[CC1Option]>, Values<"legacy,per-thread">, NormalizedValuesScope<"LangOptions::GPUDefaultStreamKind">, @@ -1171,7 +1171,7 @@ MarshallingInfoStringVector<CodeGenOpts<"OffloadObjects">>; def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">, Group<f_Group>, Flags<[NoXarchOption, CC1Option, CC1AsOption]>, MetaVarName<"<option>">, - HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">, + HelpText<"Embed LLVM bitcode">, Values<"off,all,bitcode,marker">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["Embed_Off", "Embed_All", "Embed_Bitcode", "Embed_Marker"]>, MarshallingInfoEnum<CodeGenOpts<"EmbedBitcode">, "Embed_Off">; @@ -1297,7 +1297,7 @@ ShouldParseIf<!strconcat(fprofile_arcs.KeyPath, "||", ftest_coverage.KeyPath)>; def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, Values<"atomic,prefer-atomic,single">, - MetaVarName<"<method>">, HelpText<"Set update method of profile counters (atomic,prefer-atomic,single)">, + MetaVarName<"<method>">, HelpText<"Set update method of profile counters">, MarshallingInfoFlag<CodeGenOpts<"AtomicProfileUpdate">>; defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling", CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse, @@ -1312,7 +1312,7 @@ MarshallingInfoStringVector<LangOpts<"ProfileListFiles">>; def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, MetaVarName<"<option>">, - HelpText<"Control emission of Swift async extended frame info (option: auto, always, never)">, + HelpText<"Control emission of Swift async extended frame info">, Values<"auto,always,never">, NormalizedValuesScope<"CodeGenOptions::SwiftAsyncFramePointerKind">, NormalizedValues<["Auto", "Always", "Never"]>, @@ -1483,7 +1483,7 @@ def fwasm_exceptions : Flag<["-"], "fwasm-exceptions">, Group<f_Group>, HelpText<"Use WebAssembly style exceptions">; def exception_model : Separate<["-"], "exception-model">, - Flags<[CC1Option, NoDriverOption]>, HelpText<"The exception model: dwarf|sjlj|seh|wasm">, + Flags<[CC1Option, NoDriverOption]>, HelpText<"The exception model">, Values<"dwarf,sjlj,seh,wasm">, NormalizedValuesScope<"LangOptions::ExceptionHandlingKind">, NormalizedValues<["DwarfCFI", "SjLj", "WinEH", "Wasm"]>, @@ -1665,7 +1665,7 @@ : Joined<["-"], "fsanitize-address-use-after-return=">, MetaVarName<"<mode>">, Flags<[CC1Option]>, - HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always">, + HelpText<"Select the mode of detecting stack use-after-return in AddressSanitizer">, Group<f_clang_Group>, Values<"never,runtime,always">, NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">, @@ -1954,7 +1954,7 @@ HelpText<"Instrument function entry only, after inlining, without arguments to the instrumentation call">, MarshallingInfoFlag<CodeGenOpts<"InstrumentFunctionEntryBare">>; def fcf_protection_EQ : Joined<["-"], "fcf-protection=">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, - HelpText<"Instrument control-flow architecture protection. Options: return, branch, full, none.">, Values<"return,branch,full,none">; + HelpText<"Instrument control-flow architecture protection">, Values<"return,branch,full,none">; def fcf_protection : Flag<["-"], "fcf-protection">, Group<f_Group>, Flags<[CoreOption, CC1Option]>, Alias<fcf_protection_EQ>, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; @@ -2079,7 +2079,7 @@ def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group<f_Group>, HelpText<"Force linking the clang builtins runtime library">; def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, - HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">; + HelpText<"Set LTO mode">, Values<"thin,full">; def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group<f_Group>, Alias<flto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Group<f_Group>, @@ -2089,7 +2089,7 @@ def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Disable LTO mode (default)">; def foffload_lto_EQ : Joined<["-"], "foffload-lto=">, Flags<[CoreOption]>, Group<f_Group>, - HelpText<"Set LTO mode to either 'full' or 'thin' for offload compilation">, Values<"thin,full">; + HelpText<"Set LTO mode for offload compilation">, Values<"thin,full">; def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, Group<f_Group>, Alias<foffload_lto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode for offload compilation">; def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, Group<f_Group>, @@ -2607,8 +2607,8 @@ def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>, HelpText<"Force wchar_t to be an unsigned int">; def fshow_overloads_EQ : Joined<["-"], "fshow-overloads=">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Which overload candidates to show when overload resolution fails: " - "best|all; defaults to all">, Values<"best,all">, + HelpText<"Which overload candidates to show when overload resolution fails. Defaults to all">, + Values<"best,all">, NormalizedValues<["Ovl_Best", "Ovl_All"]>, MarshallingInfoEnum<DiagnosticOpts<"ShowOverloads">, "Ovl_All">; defm show_column : BoolFOption<"show-column", @@ -2655,8 +2655,8 @@ "overwrite the guard value before overwriting the function's return " "address. The reference stack guard value is stored in a global variable.">; def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group<f_Group>, - Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack variables: uninitialized (default)" - " | pattern">, Values<"uninitialized,zero,pattern">, + Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack variables. Defaults to 'uninitialized'">, + Values<"uninitialized,zero,pattern">, NormalizedValuesScope<"LangOptions::TrivialAutoVarInitKind">, NormalizedValues<["Uninitialized", "Zero", "Pattern"]>, MarshallingInfoEnum<LangOpts<"TrivialAutoVarInit">, "Uninitialized">; @@ -2751,8 +2751,8 @@ def ftime_report_EQ: Joined<["-"], "ftime-report=">, Group<f_Group>, Flags<[CC1Option]>, Values<"per-pass,per-pass-run">, MarshallingInfoFlag<CodeGenOpts<"TimePassesPerRun">>, - HelpText<"(For new pass manager) \"per-pass\": one report for each pass; " - "\"per-pass-run\": one report for each pass invocation">; + HelpText<"(For new pass manager) 'per-pass': one report for each pass; " + "'per-pass-run': one report for each pass invocation">; def ftime_trace : Flag<["-"], "ftime-trace">, Group<f_Group>, HelpText<"Turn on time profiler. Generates JSON file based on output filename.">, DocBrief<[{ @@ -2891,7 +2891,7 @@ NegFlag<SetFalse>>; def fbasic_block_sections_EQ : Joined<["-"], "fbasic-block-sections=">, Group<f_Group>, Flags<[CC1Option, CC1AsOption]>, - HelpText<"Place each function's basic blocks in unique sections (ELF Only) : all | labels | none | list=<file>">, + HelpText<"Place each function's basic blocks in unique sections (ELF Only)">, DocBrief<[{Generate labels for each basic block or place each basic block or a subset of basic blocks in its own section.}]>, Values<"all,labels,none,list=">, MarshallingInfoString<CodeGenOpts<"BBSections">, [{"none"}]>; @@ -3055,7 +3055,7 @@ Group<g_flags_Group>; def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>; def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group<g_flags_Group>, - HelpText<"Set DWARF fission mode to either 'split' or 'single'">, + HelpText<"Set DWARF fission mode">, Values<"split,single">; def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group<g_flags_Group>; def gsimple_template_names : Flag<["-"], "gsimple-template-names">, Group<g_flags_Group>; @@ -3292,11 +3292,11 @@ HelpText<"Disable stack probes which are enabled by default">, MarshallingInfoFlag<CodeGenOpts<"NoStackArgProbe">>; def mthread_model : Separate<["-"], "mthread-model">, Group<m_Group>, Flags<[CC1Option]>, - HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">, + HelpText<"The thread model to use. Default is 'posix')">, Values<"posix,single">, NormalizedValues<["POSIX", "Single"]>, NormalizedValuesScope<"LangOptions::ThreadModelKind">, MarshallingInfoEnum<LangOpts<"ThreadModel">, "POSIX">; def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>, - HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">, + HelpText<"Set EABI type. Default depends on triple)">, Values<"default,4,5,gnu">, MarshallingInfoEnum<TargetOpts<"EABIVersion">, "Default">, NormalizedValuesScope<"llvm::EABI">, NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>; @@ -3484,7 +3484,7 @@ NegFlag<SetFalse, [CC1Option]>>, Group<m_Group>; def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>, - HelpText<"Specify code object ABI version. Allowed values are 2, 3, 4, and 5. Defaults to 4. (AMDGPU only)">, + HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">, Flags<[CC1Option]>, Values<"none,2,3,4,5">, NormalizedValuesScope<"TargetOptions">, @@ -5173,7 +5173,7 @@ HelpText<"Enable additional debug output">, MarshallingInfoString<CodeGenOpts<"DebugPass">>; def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">, - HelpText<"Specify which frame pointers to retain (all, non-leaf, none).">, Values<"all,non-leaf,none">, + HelpText<"Specify which frame pointers to retain.">, Values<"all,non-leaf,none">, NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "None"]>, MarshallingInfoEnum<CodeGenOpts<"FramePointer">, "None">; def mdisable_tail_calls : Flag<["-"], "mdisable-tail-calls">, @@ -5299,8 +5299,7 @@ HelpText<"Generate M NOPs before function entry">, MarshallingInfoInt<CodeGenOpts<"PatchableFunctionEntryOffset">>; def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, - HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, " - "or none">, Values<"none,clang,llvm,csllvm">, + HelpText<"Enable PGO instrumentation">, Values<"none,clang,llvm,csllvm">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["ProfileNone", "ProfileClangInstr", "ProfileIRInstr", "ProfileCSIRInstr"]>, MarshallingInfoEnum<CodeGenOpts<"ProfileInstr">, "ProfileNone">; @@ -5389,11 +5388,13 @@ HelpText<"File for serializing diagnostics in a binary format">; def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">, - HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,vi">, + HelpText<"Change diagnostic formatting to match IDE and command line tools">, + Values<"clang,msvc,vi">, NormalizedValuesScope<"DiagnosticOptions">, NormalizedValues<["Clang", "MSVC", "Vi"]>, MarshallingInfoEnum<DiagnosticOpts<"Format">, "Clang">; def fdiagnostics_show_category : Separate<["-"], "fdiagnostics-show-category">, - HelpText<"Print diagnostic category">, Values<"none,id,name">, + HelpText<"Print diagnostic category">, + Values<"none,id,name">, NormalizedValues<["0", "1", "2"]>, MarshallingInfoEnum<DiagnosticOpts<"ShowCategories">, "0">; def fno_diagnostics_use_presumed_location : Flag<["-"], "fno-diagnostics-use-presumed-location">, @@ -5667,7 +5668,8 @@ MarshallingInfoString<FrontendOpts<"MTMigrateDir">>; def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Flags<[CC1Option, NoDriverOption]>, - HelpText<"The ARC migration action to take">, Values<"check,modify,migrate">, + HelpText<"The ARC migration action to take">, + Values<"check,modify,migrate">, NormalizedValuesScope<"FrontendOptions">, NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>, MarshallingInfoEnum<FrontendOpts<"ARCMTAction">, "ARCMT_None">; @@ -5772,13 +5774,15 @@ HelpText<"Specify the class to use for constant Objective-C string objects.">, MarshallingInfoString<LangOpts<"ObjCConstantStringClass">>; def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, - HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">, + HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, + Values<"libc++,libstdc++,none">, NormalizedValues<["ARCXX_libcxx", "ARCXX_libstdcxx", "ARCXX_nolib"]>, MarshallingInfoEnum<PreprocessorOpts<"ObjCXXARCStandardLibrary">, "ARCXX_nolib">; def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, - HelpText<"Objective-C dispatch method to use">, Values<"legacy,non-legacy,mixed">, + HelpText<"Objective-C dispatch method to use">, + Values<"legacy,non-legacy,mixed">, NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["Legacy", "NonLegacy", "Mixed"]>, MarshallingInfoEnum<CodeGenOpts<"ObjCDispatchMethod">, "Legacy">; def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">, @@ -5825,7 +5829,8 @@ HelpText<"Should __STATIC__ be defined">, MarshallingInfoFlag<LangOpts<"Static">>; def stack_protector : Separate<["-"], "stack-protector">, - HelpText<"Enable stack protectors">, Values<"0,1,2,3">, + HelpText<"Enable stack protectors">, + Values<"0,1,2,3">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["SSPOff", "SSPOn", "SSPStrong", "SSPReq"]>, MarshallingInfoEnum<LangOpts<"StackProtector">, "SSPOff">; @@ -5868,9 +5873,10 @@ def ffake_address_space_map : Flag<["-"], "ffake-address-space-map">, HelpText<"Use a fake address space map; OpenCL testing purposes only">, MarshallingInfoFlag<LangOpts<"FakeAddressSpaceMap">>; -def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, MetaVarName<"<yes|no|target>">, +def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">, - Values<"target,no,yes">, NormalizedValuesScope<"LangOptions">, + Values<"target,no,yes">, + NormalizedValuesScope<"LangOptions">, NormalizedValues<["ASMM_Target", "ASMM_Off", "ASMM_On"]>, MarshallingInfoEnum<LangOpts<"AddressSpaceMapMangling">, "ASMM_Target">; def funknown_anytype : Flag<["-"], "funknown-anytype">, @@ -5908,7 +5914,8 @@ MarshallingInfoFlag<LangOpts<"HalfArgsAndReturns">>, ImpliedByAnyOf<[fnative_half_arguments_and_returns.KeyPath]>; def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, - HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">, + HelpText<"Set default calling convention">, + Values<"cdecl,fastcall,stdcall,vectorcall,regcall">, NormalizedValuesScope<"LangOptions">, NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", "DCC_VectorCall", "DCC_RegCall"]>, MarshallingInfoEnum<LangOpts<"DefaultCallingConv">, "DCC_None">; @@ -5923,7 +5930,8 @@ HelpText<"Preserve 3-component vector type">, MarshallingInfoFlag<CodeGenOpts<"PreserveVec3Type">>; def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, - HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">, + HelpText<"Select underlying type for wchar_t">, + Values<"char,short,int">, NormalizedValues<["1", "2", "4"]>, MarshallingInfoEnum<LangOpts<"WCharSize">, "0">; defm signed_wchar : BoolOption<"f", "signed-wchar",
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits