Small clean-up in Options.td

Hi all,

As you probably know, Clang and Flang share Options.td. When adding various options for Flang, @emilio and myself noticed a few small inconsistencies that confused us a bit. Emil kindly volunteered to improve this: ⚙ D123070 [Driver][NFC] Simplify handling of flags in Options.td.

IMHO, Emil’s patch is a very helpful improvement and I’ve already accepted it. I’m posting this here for better visibility and to make sure that there are no objections from Clang’s perspective. Perhaps you have some other suggestions too?

Thank you,
-Andrzej

BTW, why this sharing? I recently proposed to modify the pretty-printing of --help when a set of possible values is described, and that leads to flang dumping -std=c++11 as a valid choice…

https://reviews.llvm.org/D122654

Flang’s compiler driver is implemented in terms of clangDriver (the driver library in Clang). Currently, there’s only one Options.td for all options for all drivers. So, effectively, both clang and flang-new (Flang’s compiler driver) contain a table of all the available options. We made sure that clang -help would not display Flang-only options and that flang-new -help would only display options relevant in Flang.

I think that creating dedicated Options.td files would make a lot of sense and would lead to a cleaner separations between various drivers. But that would require more effort and discussion.

Thanks Andrzej for this post!

One advantage with a common Options.td is that common options can be defined and documented in one place. But as you mention, there are clearly disadvantages as well. I have not worked with the drivers enough to have an informed opinion on which way is preferable, but I at least hope this patch makes it easier to see what driver(s) an option, new or old, applies to.

1 Like