[patch] Forward all -f* options to -cc1

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Sep 27 16:13:46 PDT 2013

On 27 September 2013 18:22, Reid Kleckner <rnk at google.com> wrote:
> I don't see any reason to have a separate .td file for -f flags.  Why not
> make it easier to represent -f flags in the existing Options.td file?

Maybe I am just out of ideas, but the ways I can think of using Options.td are:

* A multiclass. Somewhat like BooleanFFlag. A problem is that we get
suffixes, not prefixes. It is also not as compact since we should
still need two help strings. It is also somewhat harder to refactor
more of the commonalities.
* Extending llvm option parsing to know about -f/-fno- flags (add a
FFlag for example). This would do it, but -f/-fno- flags are so clang
specific that this looks odd.
* Using Options.td in two tablegen invocations, one for the regular
llvm option parsing. One for a clang custom handler for -f/-fno-.
Using a new file looks cleaner.

> -W flags are special because they are already in their own domain-specific
> .td file.  I don't think that's a precedent worth following.

The simple -f/-fno- flags are not as domain specific as -W, but they
still have quiet a bit that can be refactored/unified:

* There is always a pair.
* We only need one help string for the pair.
* The last one wins.
* The only value is a bool.

It should be possible to a -f/-fno- pair by adding just one line in a
.td file with a help string and a default value and having that show
up as a field in something like CodegenOptions. I don't intend to get
this far right now, but it would be better to be on the right path.


More information about the cfe-commits mailing list