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 @@ -679,7 +679,8 @@ def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>, HelpText<"Specify name of main file output to quote in depfile">; def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>, - HelpText<"Specify name of main file output in depfile">; + HelpText<"Specify name of main file output in depfile">, + MarshallingInfoStringVector<"DependencyOutputOpts.Targets">; def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>, HelpText<"Use NMake/Jom format for the depfile">, MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", "DependencyOutputFormat::Make">, @@ -753,7 +754,8 @@ MetaVarName<"">, Group; def Wundef_prefix_EQ : CommaJoined<["-"], "Wundef-prefix=">, Group, Flags<[CC1Option, CoreOption, HelpHidden]>, MetaVarName<"">, - HelpText<"Enable warnings for undefined macros with a prefix in the comma separated list ">; + HelpText<"Enable warnings for undefined macros with a prefix in the comma separated list ">, + MarshallingInfoStringVector<"DiagnosticOpts->UndefPrefixes">; def Wwrite_strings : Flag<["-"], "Wwrite-strings">, Group, Flags<[CC1Option, HelpHidden]>; def Wno_write_strings : Flag<["-"], "Wno-write-strings">, Group, Flags<[CC1Option, HelpHidden]>; def W_Joined : Joined<["-"], "W">, Group, Flags<[CC1Option, CoreOption]>, @@ -1387,7 +1389,8 @@ Flags<[CoreOption, NoXarchOption]>; def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">, Group, - HelpText<"Path to blacklist file for sanitizers">; + HelpText<"Path to blacklist file for sanitizers">, + MarshallingInfoStringVector<"LangOpts->SanitizerBlacklistFiles">; def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">, HelpText<"Path to system blacklist file for sanitizers">, Flags<[CC1Option]>; @@ -1405,13 +1408,15 @@ "Sanitizers">, Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,inline-bool-flag">; def fsanitize_coverage_allowlist : Joined<["-"], "fsanitize-coverage-allowlist=">, Group, Flags<[CoreOption, NoXarchOption]>, - HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones">; + HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones">, + MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageAllowlistFiles">; def : Joined<["-"], "fsanitize-coverage-whitelist=">, Group, Flags<[CoreOption, HelpHidden]>, Alias, HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">; def fsanitize_coverage_blocklist : Joined<["-"], "fsanitize-coverage-blocklist=">, Group, Flags<[CoreOption, NoXarchOption]>, - HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the allowed ones">; + HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the allowed ones">, + MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageBlocklistFiles">; def : Joined<["-"], "fsanitize-coverage-blacklist=">, Group, Flags<[CoreOption, HelpHidden]>, Alias, HelpText<"Deprecated, use -fsanitize-coverage-blocklist= instead">; @@ -1616,7 +1621,8 @@ def frewrite_map_file : Separate<["-"], "frewrite-map-file">, Group, - Flags<[ NoXarchOption, CC1Option ]>; + Flags<[ NoXarchOption, CC1Option ]>, + MarshallingInfoStringVector<"CodeGenOpts.RewriteMapFiles">; def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, Group, Flags<[NoXarchOption]>; @@ -1694,15 +1700,18 @@ def fxray_always_instrument : JoinedOrSeparate<["-"], "fxray-always-instrument=">, Group, Flags<[CC1Option]>, - HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'always instrument' XRay attribute.">; + HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'always instrument' XRay attribute.">, + MarshallingInfoStringVector<"LangOpts->XRayAlwaysInstrumentFiles">; def fxray_never_instrument : JoinedOrSeparate<["-"], "fxray-never-instrument=">, Group, Flags<[CC1Option]>, - HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'never instrument' XRay attribute.">; + HelpText<"DEPRECATED: Filename defining the whitelist for imbuing the 'never instrument' XRay attribute.">, + MarshallingInfoStringVector<"LangOpts->XRayNeverInstrumentFiles">; def fxray_attr_list : JoinedOrSeparate<["-"], "fxray-attr-list=">, Group, Flags<[CC1Option]>, - HelpText<"Filename defining the list of functions/types for imbuing XRay attributes.">; + HelpText<"Filename defining the list of functions/types for imbuing XRay attributes.">, + MarshallingInfoStringVector<"LangOpts->XRayAttrListFiles">; def fxray_modes : JoinedOrSeparate<["-"], "fxray-modes=">, Group, Flags<[CC1Option]>, @@ -2191,7 +2200,8 @@ HelpText<"Load the named plugin (dynamic shared object)">; def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, Group, Flags<[CC1Option]>, MetaVarName<"">, - HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">; + HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">, + MarshallingInfoStringVector<"CodeGenOpts.PassPlugins">; defm preserve_as_comments : BoolFOption<"preserve-as-comments", "CodeGenOpts.PreserveAsmComments", DefaultsToTrue, ChangedBy, @@ -2638,7 +2648,8 @@ "absolute paths are relative to -isysroot">, MetaVarName<"">, Flags<[CC1Option]>; def imacros : JoinedOrSeparate<["-", "--"], "imacros">, Group, Flags<[CC1Option]>, - HelpText<"Include macros from file before parsing">, MetaVarName<"">; + HelpText<"Include macros from file before parsing">, MetaVarName<"">, + MarshallingInfoStringVector<"PreprocessorOpts->MacroIncludes">; def image__base : Separate<["-"], "image_base">; def include_ : JoinedOrSeparate<["-", "--"], "include">, Group, EnumName<"include">, MetaVarName<"">, HelpText<"Include file before parsing">, Flags<[CC1Option]>; @@ -2785,7 +2796,8 @@ def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, Flags<[NoXarchOption]>; def mllvm : Separate<["-"], "mllvm">, Flags<[CC1Option,CC1AsOption,CoreOption]>, - HelpText<"Additional arguments to forward to LLVM's option processing">; + HelpText<"Additional arguments to forward to LLVM's option processing">, + MarshallingInfoStringVector<"FrontendOpts.LLVMArgs">; def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">, Group, HelpText<"Set Mac OS X deployment target">; def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, @@ -3123,7 +3135,8 @@ HelpText<"Don't generate implicit floating point instructions">; def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; -def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>, + MarshallingInfoStringVector<"CodeGenOpts.Reciprocals">; def mprefer_vector_width_EQ : Joined<["-"], "mprefer-vector-width=">, Group, Flags<[CC1Option]>, HelpText<"Specifies preferred vector width for auto-vectorization. Defaults to 'none' which allows target specific decisions.">, MarshallingInfoString<"CodeGenOpts.PreferVectorWidth">; @@ -4119,7 +4132,8 @@ HelpText<"Tune for a specific cpu type">, MarshallingInfoString<"TargetOpts->TuneCPU">; def target_feature : Separate<["-"], "target-feature">, - HelpText<"Target specific attributes">; + HelpText<"Target specific attributes">, + MarshallingInfoStringVector<"TargetOpts->FeaturesAsWritten">; def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">, @@ -4322,7 +4336,8 @@ HelpText<"Emit macro debug information">, MarshallingInfoFlag<"CodeGenOpts.MacroDebugInfo">; def default_function_attr : Separate<["-"], "default-function-attr">, - HelpText<"Apply given attribute to all functions">; + HelpText<"Apply given attribute to all functions">, + MarshallingInfoStringVector<"CodeGenOpts.DefaultFunctionAttrs">; def dwarf_version_EQ : Joined<["-"], "dwarf-version=">, MarshallingInfoStringInt<"CodeGenOpts.DwarfVersion">; def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">, @@ -4495,9 +4510,11 @@ HelpText<"Run the SLP vectorization passes">, MarshallingInfoFlag<"CodeGenOpts.VectorizeSLP">; def dependent_lib : Joined<["--"], "dependent-lib=">, - HelpText<"Add dependent library">; + HelpText<"Add dependent library">, + MarshallingInfoStringVector<"CodeGenOpts.DependentLibraries">; def linker_option : Joined<["--"], "linker-option=">, - HelpText<"Add linker option">; + HelpText<"Add linker option">, + MarshallingInfoStringVector<"CodeGenOpts.LinkerOptions">; def fsanitize_coverage_type : Joined<["-"], "fsanitize-coverage-type=">, HelpText<"Sanitizer coverage type">, MarshallingInfoStringInt<"CodeGenOpts.SanitizeCoverageType">; @@ -4657,7 +4674,8 @@ def verify_EQ : CommaJoined<["-"], "verify=">, MetaVarName<"">, HelpText<"Verify diagnostic output using comment directives that start with" - " prefixes in the comma-separated sequence ">; + " prefixes in the comma-separated sequence ">, + MarshallingInfoStringVector<"DiagnosticOpts->VerifyPrefixes">; def verify : Flag<["-"], "verify">, HelpText<"Equivalent to -verify=expected">; def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">, @@ -4678,7 +4696,8 @@ def ast_merge : Separate<["-"], "ast-merge">, MetaVarName<"">, - HelpText<"Merge the given AST file into the translation unit being compiled.">; + HelpText<"Merge the given AST file into the translation unit being compiled.">, + MarshallingInfoStringVector<"FrontendOpts.ASTMergeFiles">; def aux_target_cpu : Separate<["-"], "aux-target-cpu">, HelpText<"Target a specific auxiliary cpu type">; def aux_target_feature : Separate<["-"], "aux-target-feature">, @@ -4745,11 +4764,13 @@ MarshallingInfoFlag<"HeaderSearchOpts->ModuleMapFileHomeIsCwd">; def fmodule_feature : Separate<["-"], "fmodule-feature">, MetaVarName<"">, - HelpText<"Enable in module map requires declarations">; + HelpText<"Enable in module map requires declarations">, + MarshallingInfoStringVector<"LangOpts->ModuleFeatures">; def fmodules_embed_file_EQ : Joined<["-"], "fmodules-embed-file=">, MetaVarName<"">, HelpText<"Embed the contents of the specified file into the module file " - "being compiled.">; + "being compiled.">, + MarshallingInfoStringVector<"FrontendOpts.ModulesEmbedFiles">; def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, HelpText<"Embed the contents of all files read by this compilation into " "the produced module file.">, @@ -5188,7 +5209,8 @@ //===----------------------------------------------------------------------===// def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, - HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">; + HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">, + MarshallingInfoStringVector<"TargetOpts->OpenCLExtensionsAsWritten">; //===----------------------------------------------------------------------===// // CUDA Options 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 @@ -328,7 +328,8 @@ Option::OptionClass OptClass, unsigned TableIndex, const std::vector &Values) { - if (OptClass == Option::OptionClass::CommaJoinedClass) { + switch (OptClass) { + case Option::CommaJoinedClass: { std::string CommaJoinedValue; for (const std::string &Value : Values) { if (&Value != &Values.front()) @@ -337,9 +338,17 @@ } denormalizeString(Args, Spelling, SA, Option::OptionClass::JoinedClass, TableIndex, CommaJoinedValue); - } else if (OptClass == Option::OptionClass::JoinedClass) { + break; + } + case Option::JoinedClass: + case Option::SeparateClass: + case Option::JoinedOrSeparateClass: for (const std::string &Value : Values) denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value); + break; + default: + llvm_unreachable("Cannot denormalize an option with option class " + "incompatible with string vector denormalization."); } } @@ -994,8 +1003,6 @@ } } - Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ); - // Basic Block Sections implies Function Sections. Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections) || @@ -1125,10 +1132,6 @@ } Opts.LinkBitcodeFiles.push_back(F); } - Opts.SanitizeCoverageAllowlistFiles = - Args.getAllArgValues(OPT_fsanitize_coverage_allowlist); - Opts.SanitizeCoverageBlocklistFiles = - Args.getAllArgValues(OPT_fsanitize_coverage_blocklist); Opts.SSPBufferSize = getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags); @@ -1210,8 +1213,6 @@ } } - Opts.DependentLibraries = Args.getAllArgValues(OPT_dependent_lib); - Opts.LinkerOptions = Args.getAllArgValues(OPT_linker_option); bool NeedLocTracking = false; if (!Opts.OptRecordFile.empty()) @@ -1285,8 +1286,6 @@ if (NeedLocTracking && Opts.getDebugInfo() == codegenoptions::NoDebugInfo) Opts.setDebugInfo(codegenoptions::LocTrackingOnly); - Opts.RewriteMapFiles = Args.getAllArgValues(OPT_frewrite_map_file); - // Parse -fsanitize-recover= arguments. // FIXME: Report unrecoverable sanitizers incorrectly specified here. parseSanitizerKinds("-fsanitize-recover=", @@ -1298,16 +1297,11 @@ Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true); - Opts.DefaultFunctionAttrs = Args.getAllArgValues(OPT_default_function_attr); - - Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ); - return Success; } static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts, ArgList &Args) { - Opts.Targets = Args.getAllArgValues(OPT_MT); if (Args.hasArg(OPT_show_includes)) { // Writing both /showIncludes and preprocessor output to stdout // would produce interleaved output, so use stderr for /showIncludes. @@ -1485,7 +1479,6 @@ Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits); Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location); Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ); - Opts.VerifyPrefixes = Args.getAllArgValues(OPT_verify_EQ); if (Args.hasArg(OPT_verify)) Opts.VerifyPrefixes.push_back("expected"); // Keep VerifyPrefixes in its original order for the sake of diagnostics, and @@ -1532,8 +1525,6 @@ Opts.MessageLength = getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags); - Opts.UndefPrefixes = Args.getAllArgValues(OPT_Wundef_prefix_EQ); - addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings); addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks); @@ -1730,8 +1721,6 @@ } Opts.Plugins = Args.getAllArgValues(OPT_load); - Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge); - Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm); Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ); Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ); // Only the -fmodule-file= form. @@ -1740,7 +1729,6 @@ if (Val.find('=') == StringRef::npos) Opts.ModuleFiles.push_back(std::string(Val)); } - Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ); Opts.AllowPCMWithCompilerErrors = Args.hasArg(OPT_fallow_pcm_with_errors); if (Opts.ProgramAction != frontend::GenerateModule && Opts.IsSystemModule) @@ -2557,7 +2545,6 @@ || Args.hasArg(OPT_fdump_record_layouts); if (Opts.FastRelaxedMath) Opts.setDefaultFPContractMode(LangOptions::FPM_Fast); - Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature); llvm::sort(Opts.ModuleFeatures); Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type); Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns); @@ -2768,20 +2755,12 @@ // Parse -fsanitize= arguments. parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ), Diags, Opts.Sanitize); - Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist); std::vector systemBlacklists = Args.getAllArgValues(OPT_fsanitize_system_blacklist); Opts.SanitizerBlacklistFiles.insert(Opts.SanitizerBlacklistFiles.end(), systemBlacklists.begin(), systemBlacklists.end()); - // -fxray-{always,never}-instrument= filenames. - Opts.XRayAlwaysInstrumentFiles = - Args.getAllArgValues(OPT_fxray_always_instrument); - Opts.XRayNeverInstrumentFiles = - Args.getAllArgValues(OPT_fxray_never_instrument); - Opts.XRayAttrListFiles = Args.getAllArgValues(OPT_fxray_attr_list); - if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) { Opts.setClangABICompat(LangOptions::ClangABI::Latest); @@ -2956,8 +2935,6 @@ Opts.addMacroUndef(A->getValue()); } - Opts.MacroIncludes = Args.getAllArgValues(OPT_imacros); - // Add the ordered list of -includes. for (const auto *A : Args.filtered(OPT_include)) Opts.Includes.emplace_back(A->getValue()); @@ -2996,8 +2973,6 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags) { - Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature); - Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ); Opts.AllowAMDGPUUnsafeFPAtomics = Args.hasFlag(options::OPT_munsafe_fp_atomics, options::OPT_mno_unsafe_fp_atomics, false);