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 @@ -1531,6 +1531,62 @@ def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>, HelpText<"Disable SYCL kernels compilation for device">; +def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, Flags<[CC1Option]>, + HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">, + MarshallingInfoStringInt<"LangOpts->MaxTokens">; +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">, + NormalizedValuesScope<"LangOptions::CoreFoundationABI">, + MarshallingInfoString<"LangOpts->CFRuntime", "ObjectiveC">, + NormalizedValues<["ObjectiveC", "ObjectiveC", "ObjectiveC", "Swift5_0", "Swift5_0", "Swift4_2", "Swift4_1"]>, + AutoNormalizeEnum; +def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group, Flags<[CC1Option]>, + HelpText<"Specifies the exception behavior of floating-point operations.">, + Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">, + MarshallingInfoString<"LangOpts->FPExceptionMode", "FPE_Ignore">, + NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>, AutoNormalizeEnum; +def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Group, + Flags<[CC1Option]>, HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, + NormalizedValuesScope<"LangOptions::LaxVectorConversionKind">, + MarshallingInfoString<"LangOpts->LaxVectorConversions", "All">, + NormalizedValues<["None", "Integer", "All"]>, AutoNormalizeEnum; +def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags<[CC1Option]>, + Values<"single,multiple,virtual">, + NormalizedValuesScope<"LangOptions">, + MarshallingInfoString<"LangOpts->MSPointerToMemberRepresentationMethod", "PPTMK_BestCase">, + NormalizedValues<["PPTMK_FullGeneralitySingleInheritance", "PPTMK_FullGeneralityMultipleInheritance", + "PPTMK_FullGeneralityVirtualInheritance"]>, + AutoNormalizeEnum; +def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group, + Flags<[DriverOption,CC1Option]>, MetaVarName<"">, + HelpText<"Specify the name of the module to build">, + MarshallingInfoString<"LangOpts->ModuleName">; +def fnew_alignment_EQ : Joined<["-"], "fnew-alignment=">, + HelpText<"Specifies the largest alignment guaranteed by '::operator new(size_t)'">, + MetaVarName<"">, Group, Flags<[CC1Option]>, + MarshallingInfoStringInt<"LangOpts->NewAlignOverride">; +def fpack_struct_EQ : Joined<["-"], "fpack-struct=">, Group, Flags<[CC1Option]>, + HelpText<"Specify the default maximum struct packing alignment">, + MarshallingInfoStringInt<"LangOpts->PackStruct">; +def fmax_type_align_EQ : Joined<["-"], "fmax-type-align=">, Group, Flags<[CC1Option]>, + HelpText<"Specify the maximum alignment to enforce on pointers lacking an explicit alignment">, + MarshallingInfoStringInt<"LangOpts->MaxTypeAlign">; +def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group, + Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack variables: uninitialized (default)" + " | pattern">, Values<"uninitialized,zero,pattern">, + NormalizedValuesScope<"LangOptions::TrivialAutoVarInitKind">, + MarshallingInfoString<"LangOpts->TrivialAutoVarInit", "Uninitialized">, + NormalizedValues<["Uninitialized", "Zero", "Pattern"]>, AutoNormalizeEnum; +def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group, + Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">, + MarshallingInfoStringInt<"LangOpts->TrivialAutoVarInitStopAfter">; +def Wlarge_by_value_copy_EQ : Joined<["-"], "Wlarge-by-value-copy=">, Flags<[CC1Option]>, + MarshallingInfoStringInt<"LangOpts->NumLargeByValueCopy">; +def mdouble_EQ : Joined<["-"], "mdouble=">, Group, Values<"32,64">, Flags<[CC1Option]>, +// Should this actually be enforced in CC1 + HelpText<"Force double to be 32 bits or 64 bits">, + MarshallingInfoStringInt<"LangOpts->DoubleSize", "0">; + let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { def fno_math_builtin : Flag<["-"], "fno-math-builtin">, @@ -1655,8 +1711,72 @@ HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">, MarshallingInfoFlag<"LangOpts->CUDAHostDeviceConstexpr", "true">, IsNegative; +def fconstant_string_class : Separate<["-"], "fconstant-string-class">, + MetaVarName<"">, + HelpText<"Specify the class to use for constant Objective-C string objects.">, + MarshallingInfoString<"LangOpts->ObjCConstantStringClass">; +def pic_level : Separate<["-"], "pic-level">, + HelpText<"Value for __PIC__">, + MarshallingInfoStringInt<"LangOpts->PICLevel">; +def stack_protector : Separate<["-"], "stack-protector">, + HelpText<"Enable stack protectors">, Values<"0,1,2,3">, + NormalizedValuesScope<"LangOptions">, + MarshallingInfoString<"LangOpts->StackProtector", "SSPOff">, + NormalizedValues<["SSPOff", "SSPOn", "SSPStrong", "SSPReq"]>, + AutoNormalizeEnum; +def fvisibility : Separate<["-"], "fvisibility">, + HelpText<"Default type and symbol visibility">, + Values<"default,hidden,internal,protected">, + MarshallingInfoString<"LangOpts->ValueVisibilityMode", "DefaultVisibility">, + NormalizedValues<["DefaultVisibility", "HiddenVisibility", "HiddenVisibility", "ProtectedVisibility"]>, + AutoNormalizeEnum; +def ftemplate_depth : Separate<["-"], "ftemplate-depth">, + HelpText<"Maximum depth of recursive template instantiation">, + MarshallingInfoStringInt<"LangOpts->InstantiationDepth", "1024">; +def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, + HelpText<"Maximum number of 'operator->'s to call for a member access">, + MarshallingInfoStringInt<"LangOpts->ArrowDepth", "256">; +def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, + HelpText<"Maximum depth of recursive constexpr function calls">, + MarshallingInfoStringInt<"LangOpts->ConstexprCallDepth", "512">; +def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, + HelpText<"Maximum number of steps in constexpr function evaluation">, + MarshallingInfoStringInt<"LangOpts->ConstexprStepLimit", "1048576">; +def fbracket_depth : Separate<["-"], "fbracket-depth">, + HelpText<"Maximum nesting level for parentheses, brackets, and braces">, + MarshallingInfoStringInt<"LangOpts->BracketDepth", "256">; +def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, MetaVarName<"">, + HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">, + Values<"target,no,yes">, NormalizedValuesScope<"LangOptions">, + MarshallingInfoString<"LangOpts->AddressSpaceMapMangling", "ASMM_Target">, + NormalizedValues<["ASMM_Target", "ASMM_Off", "ASMM_On"]>, AutoNormalizeEnum; +def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">, + HelpText<"Control vtordisp placement on win32 targets">, + MarshallingInfoStringInt<"LangOpts->VtorDispMode", "1">; +def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, + HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">, + NormalizedValuesScope<"LangOptions">, + MarshallingInfoString<"LangOpts->DefaultCallingConv", "DCC_None">, + NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", "DCC_VectorCall", "DCC_RegCall"]>, + AutoNormalizeEnum; +def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, + HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">, + MarshallingInfoString<"LangOpts->WCharSize", "0">, + NormalizedValues<["1", "2", "4"]>, AutoNormalizeEnum; +def function_alignment : Separate<["-"], "function-alignment">, + HelpText<"default alignment for functions">, + MarshallingInfoStringInt<"LangOpts->FunctionAlignment">; + } // Flags = [CC1Option, NoDriverOption] +let Flags = [CC1Option, CoreOption] in { + +def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, + Group, HelpText<"Level of field padding for AddressSanitizer">, + MarshallingInfoStringInt<"LangOpts->SanitizeAddressFieldPadding">; + +} // Flags = [CC1Option,CoreOption] + // Preprocessor Options def undef : Flag<["-"], "undef">, Group, Flags<[CC1Option]>, @@ -1994,8 +2114,6 @@ def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Flags<[CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; def e : JoinedOrSeparate<["-"], "e">, Group; -def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, Flags<[CC1Option]>, - HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">; def fPIC : Flag<["-"], "fPIC">, Group; def fno_PIC : Flag<["-"], "fno-PIC">, Group; def fPIE : Flag<["-"], "fPIE">, Group; @@ -2134,8 +2252,6 @@ def : Flag<["-"], "frecord-gcc-switches">, Alias; def : Flag<["-"], "fno-record-gcc-switches">, Alias; def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group; -def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group, - Flags<[CC1Option]>; def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">, Group; def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group; def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group; @@ -2198,8 +2314,6 @@ def fdenormal_fp_math_EQ : Joined<["-"], "fdenormal-fp-math=">, Group, Flags<[CC1Option]>; def ffp_model_EQ : Joined<["-"], "ffp-model=">, Group, Flags<[DriverOption]>, HelpText<"Controls the semantics of floating-point calculations.">; -def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group, Flags<[CC1Option]>, - HelpText<"Specifies the exception behavior of floating-point operations.">; defm math_errno : OptInFFlag<"math-errno", "Require math functions to indicate errors by setting errno">; def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group, Flags<[CoreOption]>; def fsignaling_math : Flag<["-"], "fsignaling-math">, Group; @@ -2253,9 +2367,6 @@ Group, Flags<[CoreOption, DriverOption]>, HelpText<"Disable origins tracking in MemorySanitizer">; -def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, - Group, - HelpText<"Level of field padding for AddressSanitizer">; // 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 // not removed since targeting either ABI will behave the same. @@ -2432,8 +2543,6 @@ HelpText<"Select which XRay instrumentation points to emit. Options: all, none, function-entry, function-exit, function, custom. Default is 'all'. 'function' includes both 'function-entry' and 'function-exit'.">; def flat__namespace : Flag<["-"], "flat_namespace">; -def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Group, - HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, Flags<[CC1Option]>; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Alias, AliasArgs<["integer"]>; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; @@ -2468,7 +2577,6 @@ HelpText<"Dot-separated value representing the Microsoft compiler " "version number to report in _MSC_VER (0 = don't define it " "(default))">; -def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags<[CC1Option]>; def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group, Flags<[DriverOption, CC1Option]>, MetaVarName<"">, HelpText<"Specify the module cache path">; @@ -2501,9 +2609,6 @@ Flags<[DriverOption, CC1Option]>, HelpText<"Enable the 'modules' language feature">; def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias; -def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group, - Flags<[DriverOption,CC1Option]>, MetaVarName<"">, - HelpText<"Specify the name of the module to build">; def fmodule_name : Separate<["-"], "fmodule-name">, Alias; def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">, Flags<[CC1Option]>, Alias; @@ -2605,9 +2710,6 @@ HelpText<"Enable C++17 aligned allocation functions">, Group; def fno_aligned_allocation: Flag<["-"], "fno-aligned-allocation">, Group, Flags<[CC1Option]>; -def fnew_alignment_EQ : Joined<["-"], "fnew-alignment=">, - HelpText<"Specifies the largest alignment guaranteed by '::operator new(size_t)'">, - MetaVarName<"">, Group, Flags<[CC1Option]>; def : Separate<["-"], "fnew-alignment">, Alias; def : Flag<["-"], "faligned-new">, Alias; def : Flag<["-"], "fno-aligned-new">, Alias; @@ -2677,10 +2779,6 @@ def foutput_class_dir_EQ : Joined<["-"], "foutput-class-dir=">, Group; def fpack_struct : Flag<["-"], "fpack-struct">, Group; def fno_pack_struct : Flag<["-"], "fno-pack-struct">, Group; -def fpack_struct_EQ : Joined<["-"], "fpack-struct=">, Group, Flags<[CC1Option]>, - HelpText<"Specify the default maximum struct packing alignment">; -def fmax_type_align_EQ : Joined<["-"], "fmax-type-align=">, Group, Flags<[CC1Option]>, - HelpText<"Specify the maximum alignment to enforce on pointers lacking an explicit alignment">; def fno_max_type_align : Flag<["-"], "fno-max-type-align">, Group; def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group, Flags<[CC1Option]>, HelpText<"Override the default ABI to return all structs on the stack">; @@ -2733,14 +2831,9 @@ "if they contain a char (or 8bit integer) array or constant sized calls to " "alloca, which are of greater size than ssp-buffer-size (default: 8 bytes). " "All variable sized calls to alloca are considered vulnerable">; -def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group, - Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack variables: uninitialized (default)" - " | pattern">, Values<"uninitialized,pattern">; def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">, Flags<[CC1Option, CoreOption]>, HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">; -def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group, - Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">; def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, Flags<[CoreOption]>, HelpText<"Emit full debug info for all types used by the program">; def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, Group, Flags<[CoreOption]>, @@ -2795,7 +2888,6 @@ def Wlarge_by_value_copy_def : Flag<["-"], "Wlarge-by-value-copy">, HelpText<"Warn if a function definition returns or accepts an object larger " "in bytes than a given value">, Flags<[HelpHidden]>; -def Wlarge_by_value_copy_EQ : Joined<["-"], "Wlarge-by-value-copy=">, Flags<[CC1Option]>; // These "special" warning flags are effectively processed as f_Group flags by the driver: // Just silence warnings about -Wlarger-than for now. @@ -3001,8 +3093,6 @@ def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, Group; def mlong_calls : Flag<["-"], "mlong-calls">, Group, HelpText<"Generate branches with extended addressability, usually via indirect jumps.">; -def mdouble_EQ : Joined<["-"], "mdouble=">, Group, Values<"32,64">, Flags<[CC1Option]>, - HelpText<"Force double to be 32 bits or 64 bits">; def LongDouble_Group : OptionGroup<"">, Group, DocName<"Long double flags">, DocBrief<[{Selects the long double implementation}]>; @@ -4631,53 +4721,24 @@ def fno_wchar : Flag<["-"], "fno-wchar">, HelpText<"Disable C++ builtin type wchar_t">; -def fconstant_string_class : Separate<["-"], "fconstant-string-class">, - MetaVarName<"">, - HelpText<"Specify the class to use for constant Objective-C string objects.">; def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">; def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; -def function_alignment : Separate<["-"], "function-alignment">, - HelpText<"default alignment for functions">; -def pic_level : Separate<["-"], "pic-level">, - HelpText<"Value for __PIC__">; def error_on_deserialized_pch_decl : Separate<["-"], "error-on-deserialized-decl">, HelpText<"Emit error if a specific declaration is deserialized from PCH, for testing">; def error_on_deserialized_pch_decl_EQ : Joined<["-"], "error-on-deserialized-decl=">, Alias; -def stack_protector : Separate<["-"], "stack-protector">, - HelpText<"Enable stack protectors">; -def fvisibility : Separate<["-"], "fvisibility">, - HelpText<"Default type and symbol visibility">; def ftype_visibility : Separate<["-"], "ftype-visibility">, HelpText<"Default type visibility">; -def ftemplate_depth : Separate<["-"], "ftemplate-depth">, - HelpText<"Maximum depth of recursive template instantiation">; -def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, - HelpText<"Maximum number of 'operator->'s to call for a member access">; -def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, - HelpText<"Maximum depth of recursive constexpr function calls">; -def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, - HelpText<"Maximum number of steps in constexpr function evaluation">; -def fbracket_depth : Separate<["-"], "fbracket-depth">, - HelpText<"Maximum nesting level for parentheses, brackets, and braces">; -def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, MetaVarName<"">, - HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">; def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-runtime">, HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">; -def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">, - HelpText<"Control vtordisp placement on win32 targets">; def fnative_half_type: Flag<["-"], "fnative-half-type">, HelpText<"Use the native half type for __fp16 instead of promoting to float">; def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and-returns">, HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">; def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, HelpText<"Allow function arguments and returns of type half">; -def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, - HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">; -def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, - HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">; // FIXME: Remove these entirely once functionality/tests have been excised. def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group, HelpText<"Use GC exclusively for Objective-C related memory management">; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -327,12 +327,36 @@ LangOpts.OptimizeSize = CodeGenOpts.OptimizeSize != 0; LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables; LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening; + LangOpts.CurrentModule = LangOpts.ModuleName; llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes); if (LangOpts.AppleKext && !LangOpts.CPlusPlus) Diags.Report(diag::warn_c_kext); + if (LangOpts.NewAlignOverride && + !llvm::isPowerOf2_32(LangOpts.NewAlignOverride)) { + Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ); + Diags.Report(diag::err_fe_invalid_alignment) + << A->getAsString(Args) << A->getValue(); + LangOpts.NewAlignOverride = 0; + } + + if (auto *Arg = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) { + llvm::Triple T(TargetOpts.Triple); + llvm::Triple::ArchType Arch = T.getArch(); + auto DefaultCC = LangOpts.getDefaultCallingConv(); + bool emitError = (DefaultCC == LangOptions::DCC_FastCall || + DefaultCC == LangOptions::DCC_StdCall) && + Arch != llvm::Triple::x86; + emitError |= (DefaultCC == LangOptions::DCC_VectorCall || + DefaultCC == LangOptions::DCC_RegCall) && + !T.isX86(); + if (emitError) + Diags.Report(diag::err_drv_argument_not_allowed_with) + << Arg->getSpelling() << T.getTriple(); + } + if (CodeGenOpts.ThreadModel != "posix" && CodeGenOpts.ThreadModel != "single") Diags.Report(diag::err_drv_invalid_value) << Args.getLastArg(OPT_mthread_model)->getAsString(Args) @@ -2228,24 +2252,6 @@ Opts.GNUInline = 1; } - if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ)) - Opts.CFRuntime = - llvm::StringSwitch(A->getValue()) - .Cases("unspecified", "standalone", "objc", - LangOptions::CoreFoundationABI::ObjectiveC) - .Cases("swift", "swift-5.0", - LangOptions::CoreFoundationABI::Swift5_0) - .Case("swift-4.2", LangOptions::CoreFoundationABI::Swift4_2) - .Case("swift-4.1", LangOptions::CoreFoundationABI::Swift4_1) - .Default(LangOptions::CoreFoundationABI::ObjectiveC); - - // The value-visibility mode defaults to "default". - if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) { - Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags)); - } else { - Opts.setValueVisibilityMode(DefaultVisibility); - } - // The type-visibility mode defaults to the value-visibility mode. if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) { Opts.setTypeVisibilityMode(parseVisibility(typeVisOpt, Args, Diags)); @@ -2285,20 +2291,6 @@ Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers, OPT_fno_dollars_in_identifiers, Opts.DollarIdents); - Opts.setVtorDispMode( - MSVtorDispMode(getLastArgIntValue(Args, OPT_vtordisp_mode_EQ, 1, Diags))); - if (Arg *A = Args.getLastArg(OPT_flax_vector_conversions_EQ)) { - using LaxKind = LangOptions::LaxVectorConversionKind; - if (auto Kind = llvm::StringSwitch>(A->getValue()) - .Case("none", LaxKind::None) - .Case("integer", LaxKind::Integer) - .Case("all", LaxKind::All) - .Default(llvm::None)) - Opts.setLaxVectorConversions(*Kind); - else - Diags.Report(diag::err_drv_invalid_value) - << A->getAsString(Args) << A->getValue(); - } // -ffixed-point Opts.FixedPoint = @@ -2352,15 +2344,6 @@ Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar); Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus20); - if (const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) { - Opts.WCharSize = llvm::StringSwitch(A->getValue()) - .Case("char", 1) - .Case("short", 2) - .Case("int", 4) - .Default(0); - if (Opts.WCharSize == 0) - Diags.Report(diag::err_fe_invalid_wchar_type) << A->getValue(); - } Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding; if (!Opts.NoBuiltin) getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs); @@ -2369,46 +2352,19 @@ Opts.AlignedAllocation); Opts.AlignedAllocationUnavailable = Opts.AlignedAllocation && Args.hasArg(OPT_aligned_alloc_unavailable); - Opts.NewAlignOverride = - getLastArgIntValue(Args, OPT_fnew_alignment_EQ, 0, Diags); - if (Opts.NewAlignOverride && !llvm::isPowerOf2_32(Opts.NewAlignOverride)) { - Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ); - Diags.Report(diag::err_fe_invalid_alignment) << A->getAsString(Args) - << A->getValue(); - Opts.NewAlignOverride = 0; - } if (Args.hasArg(OPT_fconcepts_ts)) Diags.Report(diag::warn_fe_concepts_ts_flag); // Recovery AST still heavily relies on dependent-type machinery. Opts.RecoveryAST = Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus); Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno); - Opts.InstantiationDepth = - getLastArgIntValue(Args, OPT_ftemplate_depth, 1024, Diags); - Opts.ArrowDepth = - getLastArgIntValue(Args, OPT_foperator_arrow_depth, 256, Diags); - Opts.ConstexprCallDepth = - getLastArgIntValue(Args, OPT_fconstexpr_depth, 512, Diags); - Opts.ConstexprStepLimit = - getLastArgIntValue(Args, OPT_fconstexpr_steps, 1048576, Diags); - Opts.BracketDepth = getLastArgIntValue(Args, OPT_fbracket_depth, 256, Diags); - Opts.NumLargeByValueCopy = - getLastArgIntValue(Args, OPT_Wlarge_by_value_copy_EQ, 0, Diags); - Opts.ObjCConstantStringClass = - std::string(Args.getLastArgValue(OPT_fconstant_string_class)); - Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags); - Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags); - Opts.DoubleSize = getLastArgIntValue(Args, OPT_mdouble_EQ, 0, Diags); Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128) ? 128 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0; - Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags); - Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple - || Args.hasArg(OPT_fdump_record_layouts); + Opts.DumpRecordLayouts = + Opts.DumpRecordLayoutsSimple || Args.hasArg(OPT_fdump_record_layouts); if (Opts.FastRelaxedMath) Opts.setDefaultFPContractMode(LangOptions::FPM_Fast); - Opts.ModuleName = std::string(Args.getLastArgValue(OPT_fmodule_name_EQ)); - Opts.CurrentModule = Opts.ModuleName; Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature); llvm::sort(Opts.ModuleFeatures); Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type); @@ -2430,75 +2386,6 @@ Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec, (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA)); - if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) { - switch (llvm::StringSwitch(A->getValue()) - .Case("target", LangOptions::ASMM_Target) - .Case("no", LangOptions::ASMM_Off) - .Case("yes", LangOptions::ASMM_On) - .Default(255)) { - default: - Diags.Report(diag::err_drv_invalid_value) - << "-faddress-space-map-mangling=" << A->getValue(); - break; - case LangOptions::ASMM_Target: - Opts.setAddressSpaceMapMangling(LangOptions::ASMM_Target); - break; - case LangOptions::ASMM_On: - Opts.setAddressSpaceMapMangling(LangOptions::ASMM_On); - break; - case LangOptions::ASMM_Off: - Opts.setAddressSpaceMapMangling(LangOptions::ASMM_Off); - break; - } - } - - if (Arg *A = Args.getLastArg(OPT_fms_memptr_rep_EQ)) { - LangOptions::PragmaMSPointersToMembersKind InheritanceModel = - llvm::StringSwitch( - A->getValue()) - .Case("single", - LangOptions::PPTMK_FullGeneralitySingleInheritance) - .Case("multiple", - LangOptions::PPTMK_FullGeneralityMultipleInheritance) - .Case("virtual", - LangOptions::PPTMK_FullGeneralityVirtualInheritance) - .Default(LangOptions::PPTMK_BestCase); - if (InheritanceModel == LangOptions::PPTMK_BestCase) - Diags.Report(diag::err_drv_invalid_value) - << "-fms-memptr-rep=" << A->getValue(); - - Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel); - } - - // Check for MS default calling conventions being specified. - if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) { - LangOptions::DefaultCallingConvention DefaultCC = - llvm::StringSwitch(A->getValue()) - .Case("cdecl", LangOptions::DCC_CDecl) - .Case("fastcall", LangOptions::DCC_FastCall) - .Case("stdcall", LangOptions::DCC_StdCall) - .Case("vectorcall", LangOptions::DCC_VectorCall) - .Case("regcall", LangOptions::DCC_RegCall) - .Default(LangOptions::DCC_None); - if (DefaultCC == LangOptions::DCC_None) - Diags.Report(diag::err_drv_invalid_value) - << "-fdefault-calling-conv=" << A->getValue(); - - llvm::Triple T(TargetOpts.Triple); - llvm::Triple::ArchType Arch = T.getArch(); - bool emitError = (DefaultCC == LangOptions::DCC_FastCall || - DefaultCC == LangOptions::DCC_StdCall) && - Arch != llvm::Triple::x86; - emitError |= (DefaultCC == LangOptions::DCC_VectorCall || - DefaultCC == LangOptions::DCC_RegCall) && - !T.isX86(); - if (emitError) - Diags.Report(diag::err_drv_argument_not_allowed_with) - << A->getSpelling() << T.getTriple(); - else - Opts.setDefaultCallingConv(DefaultCC); - } - // -mrtd option if (Arg *A = Args.getLastArg(OPT_mrtd)) { if (Opts.getDefaultCallingConv() != LangOptions::DCC_None) @@ -2636,7 +2523,7 @@ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val; } - // Are these really needed in CC1? + // Are these really needed in CC1? Given that they get ignored right below. if (Args.hasArg(OPT_ftrapping_math)) { Opts.setFPExceptionMode(LangOptions::FPE_Strict); } @@ -2645,6 +2532,7 @@ Opts.setFPExceptionMode(LangOptions::FPE_Ignore); } + // Is this a bug? LangOptions::FPExceptionModeKind FPEB = LangOptions::FPE_Ignore; if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) { StringRef Val = A->getValue(); @@ -2659,42 +2547,9 @@ } Opts.setFPExceptionMode(FPEB); - unsigned SSP = getLastArgIntValue(Args, OPT_stack_protector, 0, Diags); - switch (SSP) { - default: - Diags.Report(diag::err_drv_invalid_value) - << Args.getLastArg(OPT_stack_protector)->getAsString(Args) << SSP; - break; - case 0: Opts.setStackProtector(LangOptions::SSPOff); break; - case 1: Opts.setStackProtector(LangOptions::SSPOn); break; - case 2: Opts.setStackProtector(LangOptions::SSPStrong); break; - case 3: Opts.setStackProtector(LangOptions::SSPReq); break; - } - - if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init)) { - StringRef Val = A->getValue(); - if (Val == "uninitialized") - Opts.setTrivialAutoVarInit( - LangOptions::TrivialAutoVarInitKind::Uninitialized); - else if (Val == "zero") - Opts.setTrivialAutoVarInit(LangOptions::TrivialAutoVarInitKind::Zero); - else if (Val == "pattern") - Opts.setTrivialAutoVarInit(LangOptions::TrivialAutoVarInitKind::Pattern); - else - Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val; - } - - if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) { - int Val = std::stoi(A->getValue()); - Opts.TrivialAutoVarInitStopAfter = Val; - } - // Parse -fsanitize= arguments. parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ), Diags, Opts.Sanitize); - // -fsanitize-address-field-padding=N has to be a LangOpt, parse it here. - Opts.SanitizeAddressFieldPadding = - getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags); Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist); std::vector systemBlacklists = Args.getAllArgValues(OPT_fsanitize_system_blacklist); @@ -2742,8 +2597,6 @@ } } - Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags); - if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) { StringRef SignScope = A->getValue(); @@ -3029,9 +2882,6 @@ llvm::Triple T(Res.getTargetOpts().Triple); if (DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == Language::LLVM_IR) { - // PIClevel and PIELevel are needed during code generation and this should - // be set regardless of the input type. - LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags); parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ), Diags, LangOpts.Sanitize); } else { @@ -3052,9 +2902,6 @@ if (Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation())) Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect"); - LangOpts.FunctionAlignment = - getLastArgIntValue(Args, OPT_function_alignment, 0, Diags); - if (LangOpts.CUDA) { // During CUDA device-side compilation, the aux triple is the // triple used for host compilation. diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp --- a/llvm/utils/TableGen/OptParserEmitter.cpp +++ b/llvm/utils/TableGen/OptParserEmitter.cpp @@ -228,7 +228,8 @@ // Get the option groups and options. const std::vector &Groups = Records.getAllDerivedDefinitions("OptionGroup"); - std::vector Opts = Records.getAllDerivedDefinitions("Option"); + std::vector Opts = Records.getAllDerivedDefinitions("Option"); + llvm::sort(Opts.begin(), Opts.end(), LessRecordByID()); emitSourceFileHeader("Option Parsing Definitions", OS);