Skip to content

Commit 333d41e

Browse files
committed
[clang][cli] Port FrontendOpts simple string based options to new option parsing system
Depends on D84189 Reviewed By: dexonsmith Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84190
1 parent d1b3f82 commit 333d41e

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ def ccc_arcmt_modify : Flag<["-"], "ccc-arcmt-modify">, InternalDriverOpt,
542542
def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt,
543543
HelpText<"Apply modifications and produces temporary files that conform to ARC">;
544544
def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">,
545-
HelpText<"Output path for the plist report">, Flags<[CC1Option]>;
545+
HelpText<"Output path for the plist report">, Flags<[CC1Option]>,
546+
MarshallingInfoString<"FrontendOpts.ARCMTMigrateReportOut">;
546547
def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
547548
HelpText<"Emit ARC errors even if the migrator can fix them">, Flags<[CC1Option]>,
548549
MarshallingInfoFlag<"FrontendOpts.ARCMTMigrateEmitARCErrors">;
@@ -605,7 +606,8 @@ def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init
605606
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_DesignatedInitializer">;
606607

607608
def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>,
608-
HelpText<"Only modify files with a filename contained in the provided directory path">;
609+
HelpText<"Only modify files with a filename contained in the provided directory path">,
610+
MarshallingInfoString<"FrontendOpts.ObjCMTWhiteListPath">;
609611
// The misspelt "white-list" [sic] alias is due for removal.
610612
def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>,
611613
Alias<objcmt_whitelist_dir_path>;
@@ -2339,7 +2341,8 @@ can be analyzed with chrome://tracing or `Speedscope App
23392341
MarshallingInfoFlag<"FrontendOpts.TimeTrace">;
23402342
def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group<f_Group>,
23412343
HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
2342-
Flags<[CC1Option, CoreOption]>;
2344+
Flags<[CC1Option, CoreOption]>,
2345+
MarshallingInfoStringInt<"FrontendOpts.TimeTraceGranularity", "500u">;
23432346
def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group<f_Group>,
23442347
HelpText<"Print subprocess statistics">;
23452348
def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group<f_Group>,
@@ -3309,7 +3312,8 @@ def nostdlibxx : Flag<["-"], "nostdlib++">;
33093312
def object : Flag<["-"], "object">;
33103313
def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption, RenderAsInput,
33113314
CC1Option, CC1AsOption, FC1Option, FlangOption]>,
3312-
HelpText<"Write output to <file>">, MetaVarName<"<file>">;
3315+
HelpText<"Write output to <file>">, MetaVarName<"<file>">,
3316+
MarshallingInfoString<"FrontendOpts.OutputFile">;
33133317
def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">;
33143318
def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>;
33153319
def pedantic_errors : Flag<["-", "--"], "pedantic-errors">, Group<pedantic_Group>, Flags<[CC1Option]>;
@@ -4626,7 +4630,8 @@ def aux_target_cpu : Separate<["-"], "aux-target-cpu">,
46264630
def aux_target_feature : Separate<["-"], "aux-target-feature">,
46274631
HelpText<"Target specific auxiliary attributes">;
46284632
def aux_triple : Separate<["-"], "aux-triple">,
4629-
HelpText<"Auxiliary target triple.">;
4633+
HelpText<"Auxiliary target triple.">,
4634+
MarshallingInfoString<"FrontendOpts.AuxTriple">;
46304635
def code_completion_at : Separate<["-"], "code-completion-at">,
46314636
MetaVarName<"<file>:<line>:<column>">,
46324637
HelpText<"Dump code-completion information at a location">;
@@ -4672,7 +4677,8 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">,
46724677
MetaVarName<"<dump_filter>">,
46734678
HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
46744679
" nodes having a certain substring in a qualified name. Use"
4675-
" -ast-list to list all filterable declaration node names.">;
4680+
" -ast-list to list all filterable declaration node names.">,
4681+
MarshallingInfoString<"FrontendOpts.ASTDumpFilter">;
46764682
def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
46774683
HelpText<"Do not automatically generate or update the global module index">,
46784684
MarshallingInfoFlag<"FrontendOpts.UseGlobalModuleIndex", "true">, IsNegative;
@@ -4815,7 +4821,8 @@ defm emit_llvm_uselists : BoolOption<"emit-llvm-uselists",
48154821
BothFlags<[], " order of LLVM use-lists when serializing">>;
48164822

48174823
def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">,
4818-
HelpText<"Directory for temporary files produced during ARC or ObjC migration">;
4824+
HelpText<"Directory for temporary files produced during ARC or ObjC migration">,
4825+
MarshallingInfoString<"FrontendOpts.MTMigrateDir">;
48194826

48204827
def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Flags<[CC1Option, NoDriverOption]>,
48214828
HelpText<"The ARC migration action to take">, Values<"check,modify,migrate">,
@@ -4835,7 +4842,8 @@ def print_stats : Flag<["-"], "print-stats">,
48354842
HelpText<"Print performance metrics and statistics">,
48364843
MarshallingInfoFlag<"FrontendOpts.ShowStats">;
48374844
def stats_file : Joined<["-"], "stats-file=">,
4838-
HelpText<"Filename to write statistics to">;
4845+
HelpText<"Filename to write statistics to">,
4846+
MarshallingInfoString<"FrontendOpts.StatsFile">;
48394847
def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
48404848
HelpText<"Dump record layout information">;
48414849
def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
@@ -4855,7 +4863,8 @@ def fixit_to_temp : Flag<["-"], "fixit-to-temporary">,
48554863
MarshallingInfoFlag<"FrontendOpts.FixToTemporaries">;
48564864

48574865
def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">,
4858-
HelpText<"Override record layouts with those in the given file">;
4866+
HelpText<"Override record layouts with those in the given file">,
4867+
MarshallingInfoString<"FrontendOpts.OverrideRecordLayoutsFile">;
48594868
def pch_through_header_EQ : Joined<["-"], "pch-through-header=">,
48604869
HelpText<"Stop PCH generation after including this file. When using a PCH, "
48614870
"skip tokens until after this file is included.">,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,15 +1922,11 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
19221922
<< A->getAsString(Args) << A->getValue();
19231923
}
19241924

1925-
Opts.OutputFile = std::string(Args.getLastArgValue(OPT_o));
19261925
Opts.Plugins = Args.getAllArgValues(OPT_load);
1927-
Opts.TimeTraceGranularity = getLastArgIntValue(
1928-
Args, OPT_ftime_trace_granularity_EQ, Opts.TimeTraceGranularity, Diags);
19291926
Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
19301927
Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
19311928
Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
19321929
Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
1933-
Opts.ASTDumpFilter = std::string(Args.getLastArgValue(OPT_ast_dump_filter));
19341930
Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
19351931
// Only the -fmodule-file=<file> form.
19361932
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
@@ -1945,22 +1941,10 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
19451941
Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
19461942
<< "-emit-module";
19471943

1948-
Opts.OverrideRecordLayoutsFile =
1949-
std::string(Args.getLastArgValue(OPT_foverride_record_layout_EQ));
1950-
Opts.AuxTriple = std::string(Args.getLastArgValue(OPT_aux_triple));
19511944
if (Args.hasArg(OPT_aux_target_cpu))
19521945
Opts.AuxTargetCPU = std::string(Args.getLastArgValue(OPT_aux_target_cpu));
19531946
if (Args.hasArg(OPT_aux_target_feature))
19541947
Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
1955-
Opts.StatsFile = std::string(Args.getLastArgValue(OPT_stats_file));
1956-
1957-
Opts.MTMigrateDir =
1958-
std::string(Args.getLastArgValue(OPT_mt_migrate_directory));
1959-
Opts.ARCMTMigrateReportOut =
1960-
std::string(Args.getLastArgValue(OPT_arcmt_migrate_report_output));
1961-
1962-
Opts.ObjCMTWhiteListPath =
1963-
std::string(Args.getLastArgValue(OPT_objcmt_whitelist_dir_path));
19641948

19651949
if (Opts.ARCMTAction != FrontendOptions::ARCMT_None &&
19661950
Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) {

0 commit comments

Comments
 (0)