jansvoboda11 updated this revision to Diff 307577. jansvoboda11 added a comment.
Introduce OptOutPositiveFFlag, simplify a couple of boolean options with multiclasses Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83892/new/ https://reviews.llvm.org/D83892 Files: clang/include/clang/Driver/Options.td
Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -259,11 +259,12 @@ } // A boolean option which is opt-out in CC1. The negative option exists in CC1 and -// !Args.has(OPT_fno_foo) is used to check that the flag is disabled. +// Args.has(OPT_ffoo) or !Arg.has(OPT_fno_foo) is used to check that the flag is disabled. // // This is useful if the option has positive semantics (e.g. 'Autolink') that is by // default enabled (Autolink == 1), can be reaffirmed by -fautolink (Autolink == 1) // and disabled by -fno-autolink (Autolink == 0). +// todo: add ImpliedByAnyOf if necessary multiclass OptOutPositiveFFlag<string name, string pos_prefix, string neg_prefix, string help="", list<OptionFlag> flags=[], code keypath=""> { def f#NAME : Flag<["-"], "f"#name>, Flags<flags>, @@ -271,8 +272,6 @@ def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<!listconcat([CC1Option], flags)>, Group<f_Group>, HelpText<!strconcat(neg_prefix, help)>, MarshallingInfoFlag<keypath, "true">, IsNegative; - // todo: consider adding the line below when needed - // ImpliedByAnyOf<disablers, "false">; } // A boolean option which is opt-out in CC1. The negative option exists in CC1 and @@ -1915,12 +1914,8 @@ def fsplit_stack : Flag<["-"], "fsplit-stack">, Group<f_Group>; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group<f_Group>, HelpText<"Enable stack protectors for all functions">; -// todo: join the following two into OptInFFlag -def fstack_clash_protection : Flag<["-"], "fstack-clash-protection">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Enable stack clash protection">, - MarshallingInfoFlag<"CodeGenOpts.StackClashProtector">; -def fno_stack_clash_protection : Flag<["-"], "fno-stack-clash-protection">, Group<f_Group>, - HelpText<"Disable stack clash protection">; +defm stack_clash_protection : OptInFFlag<"stack-clash-protection", "Enable", "Disable", " stack clash protection", + [], "CodeGenOpts.StackClashProtector">; def fstack_protector_strong : Flag<["-"], "fstack-protector-strong">, Group<f_Group>, HelpText<"Enable stack protectors for some functions vulnerable to stack smashing. " "Compared to -fstack-protector, this uses a stronger heuristic " @@ -1961,7 +1956,6 @@ HelpText<"Enable optimizations based on the strict definition of an enum's " "value range">, MarshallingInfoFlag<"CodeGenOpts.StrictEnums">; -// fixme: finish the two below defm strict_vtable_pointers : OptInFFlag<"strict-vtable-pointers", "Enable optimizations based on the strict rules for overwriting polymorphic C++ objects", "", "", [], "CodeGenOpts.StrictVTablePointers">; @@ -1992,10 +1986,7 @@ HelpText<"Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)">, MetaVarName<"<regex>">; -// todo: merge this and point it to `CodeGenOpts.EmitGcovNotes` -def ftest_coverage : Flag<["-"], "ftest-coverage">, Flags<[CC1Option]>, Group<f_Group>, - MarshallingInfoFlag<"CodeGenOpts.EmitGcovNotes">; -def fno_test_coverage : Flag<["-"], "fno-test-coverage">, Group<f_Group>; +defm test_coverage : OptInFFlag<"test-coverage", "", "", "", [], "CodeGenOpts.EmitGcovNotes">; def fvectorize : Flag<["-"], "fvectorize">, Group<f_Group>, HelpText<"Enable the loop vectorization passes">; def fno_vectorize : Flag<["-"], "fno-vectorize">, Group<f_Group>; @@ -2061,11 +2052,8 @@ def funwind_tables : Flag<["-"], "funwind-tables">, Group<f_Group>; defm register_global_dtors_with_atexit : OptInFFlag<"register-global-dtors-with-atexit", "Use", "Don't use", " atexit or __cxa_atexit to register global destructors", [], "CodeGenOpts.RegisterGlobalDtorsWithAtExit">; -// todo: figure out why this needs to be split up -def fuse_init_array : Flag<["-"], "fuse-init-array">, Group<f_Group>; -def fno_use_init_array : Flag<["-"], "fno-use-init-array">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Use .ctors/.dtors instead of .init_array/.fini_array">, - MarshallingInfoFlag<"CodeGenOpts.UseInitArray", "true">, IsNegative; +defm use_init_array : OptOutPositiveFFlag<"use-init-array", "", "Use .ctors/.dtors instead of .init_array/.fini_array", "", + [], "CodeGenOpts.UseInitArray">; def fno_var_tracking : Flag<["-"], "fno-var-tracking">, Group<clang_ignored_f_Group>; def fverbose_asm : Flag<["-"], "fverbose-asm">, Group<f_Group>, HelpText<"Generate verbose assembly output">; @@ -2131,21 +2119,17 @@ defm unique_internal_linkage_names : OptInFFlag<"unique-internal-linkage-names", "Uniqueify Internal Linkage Symbol Names by appending the MD5 hash of the module path", "", "", [], "CodeGenOpts.UniqueInternalLinkageNames">; -// todo: join into single OptInFFlag -def funique_section_names : Flag<["-"], "funique-section-names">, Group<f_Group>; -def fno_unique_section_names : Flag<["-"], "fno-unique-section-names">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Don't use unique names for text and data sections">, - MarshallingInfoFlag<"CodeGenOpts.UniqueSectionNames", "true">, IsNegative; +defm unique_section_names : OptOutPositiveFFlag<"unique-section-names", + "", "Don't use unique names for text and data sections", "", + [], "CodeGenOpts.UniqueSectionNames">; defm split_machine_functions: OptInFFlag<"split-machine-functions", "Enable", "Disable", " late function splitting using profile information (x86 ELF)", [], "CodeGenOpts.SplitMachineFunctions">; -// todo: join into single OptInFFlag -def fstrict_return : Flag<["-"], "fstrict-return">, Group<f_Group>; -def fno_strict_return : Flag<["-"], "fno-strict-return">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"Don't treat control flow paths that fall off the end of a non-void function as unreachable">, - MarshallingInfoFlag<"CodeGenOpts.StrictReturn", "true">, IsNegative; +defm strict_return : OptOutPositiveFFlag<"strict-return", + "", "Don't treat control flow paths that fall off the end of a non-void function as unreachable", "", + [], "CodeGenOpts.StrictReturn">; def fenable_matrix : Flag<["-"], "fenable-matrix">, Group<f_Group>, Flags<[CC1Option]>, @@ -2157,11 +2141,9 @@ def fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, Group<f_Group>; defm debug_ranges_base_address : OptInFFlag<"debug-ranges-base-address", "Use DWARF base address selection entries in .debug_ranges", "", "", [], "CodeGenOpts.DebugRangesBaseAddress">; -// todo: join into single OptInFFlag -def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, Group<f_Group>, - HelpText<"Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF">; -def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group<f_Group>, - Flags<[CC1Option]>, MarshallingInfoFlag<"CodeGenOpts.SplitDwarfInlining", "true">, IsNegative; +defm split_dwarf_inlining : OptOutPositiveFFlag<"split-dwarf-inlining", + "Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF", "", "", + [], "CodeGenOpts.SplitDwarfInlining">; def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, Group<f_Group>, HelpText<"Default DWARF version to use, if a -g option caused DWARF debug info to be produced">; def fdebug_prefix_map_EQ @@ -2215,7 +2197,7 @@ Flags<[CC1Option, CoreOption]>, MarshallingInfoFlag<"CodeGenOpts.CodeViewGHash">; def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, Flags<[CoreOption]>; -// todo: join following into single OptInFFlag (what about Flags though?) +// todo: simplify these into a version of OptOutFFlag that doesn't imply `f_Group` and `f` in names def ginline_line_tables : Flag<["-"], "ginline-line-tables">, Flags<[CoreOption]>; def gno_inline_line_tables : Flag<["-"], "gno-inline-line-tables">, Flags<[CC1Option, CoreOption]>, HelpText<"Don't emit inline line tables">, @@ -2236,7 +2218,7 @@ def : Flag<["-"], "gno-record-gcc-switches">, Alias<gno_record_command_line>; def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group<g_flags_Group>; def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group<g_flags_Group>; -// todo: try to merge into one OptOutFlag +// todo: simplify these into a version of OptOutPositiveFFlag that doesn't imply `f_Group` and `f` in names def gcolumn_info : Flag<["-"], "gcolumn-info">, Group<g_flags_Group>, Flags<[CoreOption]>; def gno_column_info : Flag<["-"], "gno-column-info">, Group<g_flags_Group>, Flags<[CoreOption, CC1Option]>, MarshallingInfoFlag<"CodeGenOpts.DebugColumnInfo", "true">, IsNegative; @@ -2713,7 +2695,7 @@ def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group<m_Group>, HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">, Flags<[CC1Option]>; -// todo: join into single OptOutMFlag +// todo: simplify these into a version of OptInFFlag that doesn't imply `f_Group`, `f` in names and Flags def mbackchain : Flag<["-"], "mbackchain">, Group<m_Group>, Flags<[NoXarchOption,CC1Option]>, HelpText<"Link stack frames through backchain on System Z">, MarshallingInfoFlag<"CodeGenOpts.Backchain">; @@ -2758,7 +2740,7 @@ HelpText<"Use the given offset for addressing the stack-protector guard">; def mstack_protector_guard_reg_EQ : Joined<["-"], "mstack-protector-guard-reg=">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Use the given reg for addressing the stack-protector guard">; -// todo: join into OptInMFlag +// todo: simplify these into a version of OptInFFlag that doesn't imply `f_Group` and `f` in names def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Use copy relocations support for PIE builds">, @@ -4422,7 +4404,7 @@ HelpText<"Print the output of the dependency directives source minimizer">; } -// todo: join into one OptInFlag +// todo: simplify this into a version of OptInFFlag that doesn't imply `f_Group` and `f` in names, append CC1Option flag def no_emit_llvm_uselists : Flag<["-"], "no-emit-llvm-uselists">, HelpText<"Don't preserve order of LLVM use-lists when serializing">; def emit_llvm_uselists : Flag<["-"], "emit-llvm-uselists">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits