<div dir="ltr"><div>How about we model "-f" as a prefix similar to "--", and then use some tablegen construct to create the -f and -fno- versions, as well as potentially populating a .def file from it like you suggest?</div>
<div><br></div><div>The only problem I see with this is that I commonly search the .td files for "ffoo", and that wouldn't fire anymore.</div><div><br></div>On Fri, Sep 27, 2013 at 8:36 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There are some special -f options that are not really flags. For<br>
example, -fprofile-dir=PATH. It takes a value and there is no such<br>
thing as -fno-profile-dir. For these special cases it looks like we<br>
have a fairly reasonable infrastructure, since they will need some<br>
custom handling anyway.<br>
<br>
But the vast majority are just simple flags that have the form of the<br>
pair -ffoo and -fno-foo. Right now we have quiet a large amount of<br>
boilerplate to implement those.<br>
<br>
* Add both to Options.td:<br>
<br>
def fshow_column : Flag<["-"], "fshow-column">, Group<f_Group>,<br>
Flags<[CC1Option]>;<br>
def fno_show_column : Flag<["-"], "fno-show-column">, Group<f_Group>,<br>
Flags<[CC1Option]>,<br>
  HelpText<"Do not include column number on diagnostics">;<br>
<br>
* Add it to some .def file.<br>
<br>
DIAGOPT(ShowColumn, 1, 1)       /// Show column number on diagnostics.<br>
<br>
* Parse the option:<br>
<br>
Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,<br>
                                 OPT_fno_show_column,<br>
                                 /*Default=*/true);<br>
<br>
* Actually use the option for what it is intended.<br>
<br>
Because of this, most -f options have some bug in their<br>
implementation. In the above fshow-column example the help text is out<br>
of sync, the negative of -ffunction-sections is missing completely,<br>
etc.<br>
<br>
I think that to fix this we need something more like the way we handle warnings:<br>
<br>
* Add a catch all -f* option to Options.td.<br>
* Add a include/Basic/FFlags.td with entries like<br>
<br>
def show_column : FFlag<"Include column number on diagnostics", 1>;<br>
<br>
Where 1 is the default value.<br>
<br>
* Have tablegen produce a FFlags.def file and a function for setting<br>
the flags from the command line options.<br>
<br>
* Produce a -f specific error if we see one that we don't know what it<br>
is ("unknown flag: 'foobar'", instead of "unknown argument:<br>
'-ffoobar'").<br>
<br>
Can anyone see a problem with this? The main difference (other than<br>
the refactoring) would be that all the f flags are in singe .def file<br>
and object, not split in CodeGenOptions.def/CodeGenOptions,<br>
DiagnosticOptions.def/DiagnosticOptions, etc.<br>
<br>
Cheers,<br>
Rafael<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>