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 @@ -375,10 +375,10 @@ // BoolOption is the API that should be used most of the time. Use this only // when you need more control (e.g. to represent a marshalled option whose // keypath defaults to an arbitrarily complex boolean expression). -multiclass BoolOptionBase, - string prefix = ""> { + FlagDefSuffix flags_suffix = FlagDefSuffix<[], "">> { defvar flag1 = FlagDefExpanded.Result, prefix, NAME, spelling_base>; @@ -436,29 +436,28 @@ /// Creates two command line flags that control the same boolean keypath. /// /// Example: -/// defm my_boolean_option : BoolOption<"my-boolean-option", +/// defm my_boolean_option : BoolOption<"f", "my-boolean-option", /// CodeGenOpts<"MyBooleanOption">, DefaultsToFalse, /// ChangedBy, /// ResetBy, /// BothFlags<[CoreOption], " my boolean option.">; /// /// The Clang driver now knows two new command line flags: the "positive" -/// -my-boolean-option and the "negative" -no-my-boolean-option. The positive -/// flag is also available on the CC1 command line. +/// -fmy-boolean-option and the "negative" -fno-my-boolean-option. The +/// positive flag is also available on the CC1 command line. /// /// * When the command line contains neither of the flags, the keypath value /// defaults to false. /// * When the command line contains the positive -my-boolean-option, the /// keypath value changes to true. -/// * When the command line contains the negative -no-my-bool-option, the +/// * When the command line contains the negative -fno-my-bool-option, the /// keypath value resets to false. /// /// The help text for -my-boolean-option is "Enable my boolean option." and -/// "Disable my boolean option." for -no-my-boolean-option. -multiclass BoolOption, - string name_prefix = ""> { + ResetBy reset_by, BothFlags both = BothFlags<[], "">> { defvar default = Default; defvar changed_by_flag = FlagDef; - defm NAME : BoolOptionBase; + defm NAME : BoolOptionBase; } /// Creates a BoolOption with the changing available on the CC1 command line. -multiclass BoolCC1Option, - string name_prefix = ""> { + ResetBy reset_by, BothFlags both = BothFlags<[], "">> { defvar changed_by_cc1 = ChangedBy; - defm NAME : BoolOption; + defm NAME : BoolOption; } /// Creates a BoolOption where both of the flags are prefixed with "f", are in @@ -494,8 +492,8 @@ multiclass BoolFOption> { - defm NAME : BoolCC1Option, + defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by, + reset_by, both>, Group; } @@ -505,8 +503,8 @@ multiclass BoolGOption> { - defm NAME : BoolCC1Option, + defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by, + reset_by, both>, Group; } @@ -1269,11 +1267,11 @@ Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">, MarshallingInfoNegativeFlag>; def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group; -defm complete_member_pointers : BoolOption<"complete-member-pointers", +defm complete_member_pointers : BoolOption<"f", "complete-member-pointers", LangOpts<"CompleteMemberPointers">, DefaultsToFalse, ChangedBy, ResetBy, BothFlags<[CoreOption], " member pointer base types to be complete if they" - " would be significant under the Microsoft ABI">, "f">, + " would be significant under the Microsoft ABI">>, Group; def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group, Flags<[CC1Option]>, Values<"unspecified,standalone,objc,swift,swift-5.0,swift-4.2,swift-4.1">, @@ -1495,33 +1493,33 @@ Group, Flags<[CoreOption, NoXarchOption]>, HelpText<"Disable origins tracking in MemorySanitizer">; -defm sanitize_memory_use_after_dtor : BoolOption<"sanitize-memory-use-after-dtor", +defm sanitize_memory_use_after_dtor : BoolOption<"f", "sanitize-memory-use-after-dtor", CodeGenOpts<"SanitizeMemoryUseAfterDtor">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " use-after-destroy detection in MemorySanitizer">, "f">, + BothFlags<[], " use-after-destroy detection in MemorySanitizer">>, Group; def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, Group, HelpText<"Level of field padding for AddressSanitizer">, MarshallingInfoStringInt>; -defm sanitize_address_use_after_scope : BoolOption<"sanitize-address-use-after-scope", +defm sanitize_address_use_after_scope : BoolOption<"f", "sanitize-address-use-after-scope", CodeGenOpts<"SanitizeAddressUseAfterScope">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " use-after-scope detection in AddressSanitizer">, "f">, + BothFlags<[], " use-after-scope detection in AddressSanitizer">>, Group; -defm sanitize_address_poison_custom_array_cookie : BoolOption<"sanitize-address-poison-custom-array-cookie", +defm sanitize_address_poison_custom_array_cookie : BoolOption<"f", "sanitize-address-poison-custom-array-cookie", CodeGenOpts<"SanitizeAddressPoisonCustomArrayCookie">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " poisoning array cookies when using custom operator new[] in AddressSanitizer">, "f">, + BothFlags<[], " poisoning array cookies when using custom operator new[] in AddressSanitizer">>, Group; def fsanitize_address_globals_dead_stripping : Flag<["-"], "fsanitize-address-globals-dead-stripping">, Group, HelpText<"Enable linker dead stripping of globals in AddressSanitizer">, MarshallingInfoFlag, "false">; -defm sanitize_address_use_odr_indicator : BoolOption<"sanitize-address-use-odr-indicator", +defm sanitize_address_use_odr_indicator : BoolOption<"f", "sanitize-address-use-odr-indicator", CodeGenOpts<"SanitizeAddressUseOdrIndicator">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[]>, "f">, + ResetBy>, Group; // Note: This flag was introduced when it was necessary to distinguish between // ABI for correct codegen. This is no longer needed, but the flag is @@ -1562,9 +1560,9 @@ def fno_sanitize_undefined_trap_on_error : Flag<["-"], "fno-sanitize-undefined-trap-on-error">, Group, Alias, AliasArgs<["undefined"]>; -defm sanitize_minimal_runtime : BoolOption<"sanitize-minimal-runtime", +defm sanitize_minimal_runtime : BoolOption<"f", "sanitize-minimal-runtime", CodeGenOpts<"SanitizeMinimalRuntime">, DefaultsToFalse, - ChangedBy, ResetBy, BothFlags<[]>, "f">, + ChangedBy, ResetBy>, Group; def fsanitize_link_runtime : Flag<["-"], "fsanitize-link-runtime">, Group; @@ -1574,24 +1572,24 @@ Group; def fno_sanitize_link_cxx_runtime : Flag<["-"], "fno-sanitize-link-c++-runtime">, Group; -defm sanitize_cfi_cross_dso : BoolOption<"sanitize-cfi-cross-dso", +defm sanitize_cfi_cross_dso : BoolOption<"f", "sanitize-cfi-cross-dso", CodeGenOpts<"SanitizeCfiCrossDso">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " control flow integrity (CFI) checks for cross-DSO calls.">, "f">, + BothFlags<[], " control flow integrity (CFI) checks for cross-DSO calls.">>, Group; def fsanitize_cfi_icall_generalize_pointers : Flag<["-"], "fsanitize-cfi-icall-generalize-pointers">, Group, HelpText<"Generalize pointers in CFI indirect call type signature checks">, MarshallingInfoFlag>; -defm sanitize_cfi_canonical_jump_tables : BoolOption<"sanitize-cfi-canonical-jump-tables", +defm sanitize_cfi_canonical_jump_tables : BoolOption<"f", "sanitize-cfi-canonical-jump-tables", CodeGenOpts<"SanitizeCfiCanonicalJumpTables">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " the jump table addresses canonical in the symbol table">, "f">, + BothFlags<[], " the jump table addresses canonical in the symbol table">>, Group; -defm sanitize_stats : BoolOption<"sanitize-stats", +defm sanitize_stats : BoolOption<"f", "sanitize-stats", CodeGenOpts<"SanitizeStats">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " sanitizer statistics gathering.">, "f">, + BothFlags<[], " sanitizer statistics gathering.">>, Group; def fsanitize_thread_memory_access : Flag<["-"], "fsanitize-thread-memory-access">, Group, @@ -1720,11 +1718,11 @@ HelpText<"Enables the global instruction selector">; def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group, Alias; -defm legacy_pass_manager : BoolOptionBase<"legacy-pass-manager", +defm legacy_pass_manager : BoolOptionBase<"f", "legacy-pass-manager", CodeGenOpts<"LegacyPassManager">, Default<"!static_cast(LLVM_ENABLE_NEW_PASS_MANAGER)">, FlagDef, FlagDef, - FlagDefSuffix<[CC1Option], "">, "f">, Group; + FlagDefSuffix<[CC1Option], "">>, Group; def fexperimental_new_pass_manager : Flag<["-"], "fexperimental-new-pass-manager">, Group, Flags<[CC1Option]>, Alias; def fno_experimental_new_pass_manager : Flag<["-"], "fno-experimental-new-pass-manager">, @@ -1816,11 +1814,11 @@ MarshallingInfoStringInt, "0">; -defm fine_grained_bitfield_accesses : BoolOption<"fine-grained-bitfield-accesses", +defm fine_grained_bitfield_accesses : BoolOption<"f", "fine-grained-bitfield-accesses", CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[CC1Option]>, "f">, + BothFlags<[CC1Option]>>, Group; defm experimental_relative_cxx_abi_vtables : BoolFOption<"experimental-relative-c++-abi-vtables", @@ -1937,10 +1935,10 @@ Group, Flags<[CC1Option]>, HelpText<"Disable validation of the diagnostic options when loading the module">, MarshallingInfoNegativeFlag>; -defm modules_validate_system_headers : BoolOption<"modules-validate-system-headers", +defm modules_validate_system_headers : BoolOption<"f", "modules-validate-system-headers", HeaderSearchOpts<"ModulesValidateSystemHeaders">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[]>, "f">, Group; + ResetBy>, Group; def fvalidate_ast_input_files_content: Flag <["-"], "fvalidate-ast-input-files-content">, @@ -2667,10 +2665,10 @@ HelpText<"Generate CodeView debug information">, Flags<[CC1Option, CC1AsOption, CoreOption]>, MarshallingInfoFlag>; -defm codeview_ghash : BoolOption<"codeview-ghash", +defm codeview_ghash : BoolOption<"g", "codeview-ghash", CodeGenOpts<"CodeViewGHash">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[CoreOption]>, "g">; + ResetBy, BothFlags<[CoreOption]>>; defm inline_line_tables : BoolGOption<"inline-line-tables", CodeGenOpts<"NoInlineLineTables">, DefaultsToFalse, ChangedBy, @@ -2691,9 +2689,9 @@ def : Flag<["-"], "gno-record-gcc-switches">, Alias; def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group; def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group; -defm column_info : BoolCC1Option<"column-info", +defm column_info : BoolCC1Option<"g", "column-info", CodeGenOpts<"DebugColumnInfo">, DefaultsToTrue, - ChangedBy, ResetBy, BothFlags<[CoreOption]>, "g">, + ChangedBy, ResetBy, BothFlags<[CoreOption]>>, Group; def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group; def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group, @@ -2938,10 +2936,10 @@ def mretpoline : Flag<["-"], "mretpoline">, Group, Flags<[CoreOption,NoXarchOption]>; def mno_retpoline : Flag<["-"], "mno-retpoline">, Group, Flags<[CoreOption,NoXarchOption]>; -defm speculative_load_hardening : BoolOption<"speculative-load-hardening", +defm speculative_load_hardening : BoolOption<"m", "speculative-load-hardening", CodeGenOpts<"SpeculativeLoadHardening">, DefaultsToFalse, - ChangedBy, ResetBy, BothFlags<[CoreOption]>, - "m">, Group; + ChangedBy, ResetBy, BothFlags<[CoreOption]>>, + Group; def mlvi_hardening : Flag<["-"], "mlvi-hardening">, Group, Flags<[CoreOption,NoXarchOption]>, HelpText<"Enable all mitigations for Load Value Injection (LVI)">; def mno_lvi_hardening : Flag<["-"], "mno-lvi-hardening">, Group, Flags<[CoreOption,NoXarchOption]>, @@ -3006,12 +3004,12 @@ Flags<[NoXarchOption,CC1Option]>, HelpText<"Follows the AAPCS standard that all volatile bit-field write generates at least one load. (ARM only).">, MarshallingInfoFlag>; -defm aapcs_bitfield_width : BoolOption<"aapcs-bitfield-width", +defm aapcs_bitfield_width : BoolOption<"f", "aapcs-bitfield-width", CodeGenOpts<"AAPCSBitfieldWidth">, DefaultsToTrue, ChangedBy, ResetBy, BothFlags<[NoXarchOption, CC1Option], " the AAPCS standard requirement stating that" - " volatile bit-field width is dictated by the field container type. (ARM only).">, - "f">, Group; + " volatile bit-field width is dictated by the field container type. (ARM only).">>, + Group; def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group, HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">; @@ -3090,10 +3088,10 @@ def mno_wavefrontsize64 : Flag<["-"], "mno-wavefrontsize64">, Group, HelpText<"Specify wavefront size 32 mode (AMDGPU only)">; -defm unsafe_fp_atomics : BoolCC1Option<"unsafe-fp-atomics", +defm unsafe_fp_atomics : BoolCC1Option<"m", "unsafe-fp-atomics", TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[]>, "m">, Group; + ResetBy>, Group; def faltivec : Flag<["-"], "faltivec">, Group, Flags<[NoXarchOption]>; def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[NoXarchOption]>; @@ -3186,10 +3184,10 @@ def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group, HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">, Flags<[CC1Option]>; -defm backchain : BoolOption<"backchain", +defm backchain : BoolOption<"m", "backchain", CodeGenOpts<"Backchain">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[NoXarchOption,CC1Option]>, "m">, Group; + ResetBy, BothFlags<[NoXarchOption,CC1Option]>>, Group; def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group; @@ -3488,7 +3486,7 @@ HelpText<"Print the registered targets">; def private__bundle : Flag<["-"], "private_bundle">; def pthreads : Flag<["-"], "pthreads">; -defm pthread : BoolOption<"pthread", +defm pthread : BoolOption<"", "pthread", LangOpts<"POSIXThreads">, DefaultsToFalse, ChangedBy, ResetBy, BothFlags<[CC1Option]>>; @@ -4193,10 +4191,10 @@ defm whole_file : BooleanFFlag<"whole-file">, Group; // C++ SYCL options -defm sycl : BoolOption<"sycl", +defm sycl : BoolOption<"f", "sycl", LangOpts<"SYCL">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">, + BothFlags<[CoreOption], " SYCL kernels compilation for device">>, Group; def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, HelpText<"SYCL language standard to compile for.">, Values<"2017,121,1.2.1,sycl-1.2.1">, @@ -4697,15 +4695,14 @@ Flag<["-"], "flto-visibility-public-std">, HelpText<"Use public LTO visibility for classes in std and stdext namespaces">, MarshallingInfoFlag>; -defm lto_unit : BoolCC1Option<"lto-unit", +defm lto_unit : BoolCC1Option<"f", "lto-unit", CodeGenOpts<"LTOUnit">, DefaultsToFalse, ChangedBy, - ResetBy, BothFlags<[]>, "f">; -defm debug_pass_manager : BoolOption<"debug-pass-manager", + ResetBy>; +defm debug_pass_manager : BoolOption<"f", "debug-pass-manager", CodeGenOpts<"DebugPassManager">, DefaultsToFalse, ChangedBy, - ResetBy, - BothFlags<[]>, "f">; + ResetBy>; def fexperimental_debug_variable_locations : Flag<["-"], "fexperimental-debug-variable-locations">, HelpText<"Use experimental new value-tracking variable locations">, @@ -4924,16 +4921,14 @@ HelpText<"Disable satisfaction caching for C++2a Concepts.">, MarshallingInfoNegativeFlag>; -defm recovery_ast : BoolOption<"recovery-ast", +defm recovery_ast : BoolOption<"f", "recovery-ast", LangOpts<"RecoveryAST">, DefaultsToTrue, ChangedBy, ResetBy, - BothFlags<[]>, "f">; -defm recovery_ast_type : BoolOption<"recovery-ast-type", + "than dropping them when encountering semantic errors">>; +defm recovery_ast_type : BoolOption<"f", "recovery-ast-type", LangOpts<"RecoveryASTType">, DefaultsToTrue, ChangedBy, ResetBy, - BothFlags<[]>, "f">; + "expressions when possible">>; let Group = Action_Group in { @@ -5007,7 +5002,7 @@ HelpText<"Print the output of the dependency directives source minimizer">; } -defm emit_llvm_uselists : BoolOption<"emit-llvm-uselists", +defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", CodeGenOpts<"EmitLLVMUseLists">, DefaultsToFalse, ChangedBy, ResetBy, @@ -5191,10 +5186,10 @@ def fbracket_depth : Separate<["-"], "fbracket-depth">, HelpText<"Maximum nesting level for parentheses, brackets, and braces">, MarshallingInfoStringInt, "256">; -defm const_strings : BoolCC1Option<"const-strings", +defm const_strings : BoolCC1Option<"f", "const-strings", LangOpts<"ConstStrings">, DefaultsToFalse, ChangedBy, ResetBy, - BothFlags<[], " a const qualified type for string literals in C and ObjC">, "f">; + BothFlags<[], " a const qualified type for string literals in C and ObjC">>; def fno_bitfield_type_align : Flag<["-"], "fno-bitfield-type-align">, HelpText<"Ignore bit-field types when aligning structures">, MarshallingInfoFlag>; @@ -5253,10 +5248,10 @@ HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">, NormalizedValues<["1", "2", "4"]>, MarshallingInfoString, "0">, AutoNormalizeEnum; -defm signed_wchar : BoolCC1Option<"signed-wchar", +defm signed_wchar : BoolCC1Option<"f", "signed-wchar", LangOpts<"WCharIsSigned">, DefaultsToTrue, ChangedBy, ResetBy, - BothFlags<[], " type for wchar_t">, "f">; + BothFlags<[], " type for wchar_t">>; def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], "fcompatibility-qualified-id-block-type-checking">, HelpText<"Allow using blocks with parameters of more specific type than " "the type system guarantees when a parameter is qualified id">,