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 @@ -390,6 +390,33 @@ def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>, MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments", "false">; +// Dependency Output Options + +def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>, + HelpText<"Use NMake/Jom format for the depfile">, + MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", "DependencyOutputFormat::Make">, + Normalizer<"(normalizeFlagToValue)">; +def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group, + HelpText<"Show header includes and nesting depth">, + MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes", "false">; +def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>, + HelpText<"Add missing headers to depfile">, + MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps", "false">; +def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>, + HelpText<"Create phony target for each dependency (other than main file)">, + MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets", "false">; + +let Flags = [CC1Option, NoDriverOption] in { + +def sys_header_deps : Flag<["-"], "sys-header-deps">, + HelpText<"Include system headers in dependency output">, + MarshallingInfoFlag<"DependencyOutputOpts.IncludeSystemHeaders", "false">; +def module_file_deps : Flag<["-"], "module-file-deps">, + HelpText<"Include module files in dependency output">, + MarshallingInfoFlag<"DependencyOutputOpts.IncludeModuleFiles", "false">; + +} // Flags = [CC1Option, NoDriverOption] + // Standard Options def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>, @@ -414,8 +441,6 @@ MetaVarName<"">, HelpText<"Put objects of at most bytes " "into small data section (MIPS / Hexagon)">; def G_EQ : Joined<["-"], "G=">, Flags<[DriverOption]>, Group, Alias; -def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group, - HelpText<"Show header includes and nesting depth">; def I_ : Flag<["-"], "I-">, Group, HelpText<"Restrict all prior -I flags to double-quoted inclusion and " "remove current directory from include path">; @@ -435,18 +460,12 @@ def MF : JoinedOrSeparate<["-"], "MF">, Group, HelpText<"Write depfile output from -MMD, -MD, -MM, or -M to ">, MetaVarName<"">; -def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>, - HelpText<"Add missing headers to depfile">; def MJ : JoinedOrSeparate<["-"], "MJ">, Group, HelpText<"Write a compilation database entry per input">; -def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>, - HelpText<"Create phony target for each dependency (other than main file)">; 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">; -def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>, - HelpText<"Use NMake/Jom format for the depfile">; def Mach : Flag<["-"], "Mach">, Group; def O0 : Flag<["-"], "O0">, Group, Flags<[CC1Option, HelpHidden]>; def O4 : Flag<["-"], "O4">, Group, Flags<[CC1Option, HelpHidden]>; @@ -3899,10 +3918,6 @@ // Dependency Output Options //===----------------------------------------------------------------------===// -def sys_header_deps : Flag<["-"], "sys-header-deps">, - HelpText<"Include system headers in dependency output">; -def module_file_deps : Flag<["-"], "module-file-deps">, - HelpText<"Include module files in dependency output">; def header_include_file : Separate<["-"], "header-include-file">, HelpText<"Filename (or -) to write header include output to">; def show_includes : Flag<["--"], "show-includes">, 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 @@ -138,10 +138,11 @@ return !Args.hasArg(Opt); } +template void denormalizeSimpleFlag(SmallVectorImpl &Args, const char *Spelling, CompilerInvocation::StringAllocator SA, - unsigned TableIndex, unsigned Value) { + unsigned TableIndex, T Value) { Args.push_back(Spelling); } @@ -1521,13 +1522,8 @@ ArgList &Args) { Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file)); Opts.Targets = Args.getAllArgValues(OPT_MT); - Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps); - Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps); - Opts.UsePhonyTargets = Args.hasArg(OPT_MP); - Opts.ShowHeaderIncludes = Args.hasArg(OPT_H); Opts.HeaderIncludeOutputFile = std::string(Args.getLastArgValue(OPT_header_include_file)); - Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG); if (Args.hasArg(OPT_show_includes)) { // Writing both /showIncludes and preprocessor output to stdout // would produce interleaved output, so use stderr for /showIncludes. @@ -1542,8 +1538,6 @@ Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot)); Opts.ModuleDependencyOutputDir = std::string(Args.getLastArgValue(OPT_module_dependency_dir)); - if (Args.hasArg(OPT_MV)) - Opts.OutputFormat = DependencyOutputFormat::NMake; // Add sanitizer blacklists as extra dependencies. // They won't be discovered by the regular preprocessor, so // we let make / ninja to know about this implicit dependency.