This is an archive of the discontinued LLVM Phabricator instance.

[Option] Add "Visibility" field and clone the OptTable APIs to use it
ClosedPublic

Authored by bogner on Aug 4 2023, 3:50 PM.

Details

Summary

This splits OptTable's "Flags" field into "Flags" and "Visibility",
updates the places where we instantiate Option tables, and adds
variants of the OptTable APIs that use Visibility mask instead of
Include/Exclude flags.

We need to do this to clean up a bunch of complexity in the clang
driver's option handling - there's a whole slew of flags like
CoreOption, NoDriverOption, and FlangOnlyOption there today to try to
handle all of the permutations of flags that the various drivers need,
but it really doesn't scale well, as can be seen by things like the
somewhat recently introduced CLDXCOption.

Instead, we'll provide an additive model for visibility that's
separate from the other flags. For things like "HelpHidden", which is
used as a "subtractive" modifier for option visibility, we leave that
in "Flags" and handle it as a special case.

Note that we don't actually update the users of the Include/Exclude
APIs here or change the flags that exist in clang at all - that will
come in a follow up that refactors clang's Options.td to use the
increased flexibility this change allows.

Diff Detail

Event Timeline

bogner created this revision.Aug 4 2023, 3:50 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added subscribers: pmatos, asb, ormris and 6 others. · View Herald Transcript
bogner requested review of this revision.Aug 4 2023, 3:50 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptAug 4 2023, 3:50 PM
bogner updated this revision to Diff 548832.Aug 9 2023, 5:39 PM

Rebase/resolve conflicts

bogner updated this revision to Diff 549111.Aug 10 2023, 11:05 AM

Resolve conflicts

MaskRay accepted this revision.Aug 14 2023, 12:26 PM
MaskRay added subscribers: python3kgae, beanz.

... but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption.

FYI @beanz @python3kgae D128462

llvm/utils/TableGen/OptParserEmitter.cpp
387

If we make "flags" & "visibility", it's best not to use "visibility flags" to add possible confusion to readers.

This also applies to this sentence in the summary ... the only "subtractive" visibility flag be "HelpHidden"

This revision is now accepted and ready to land.Aug 14 2023, 12:26 PM
bogner updated this revision to Diff 550055.Aug 14 2023, 12:38 PM
bogner edited the summary of this revision. (Show Details)

Update comment wording to be less ambiguous about flags vs visibility

bogner marked an inline comment as done.Aug 14 2023, 12:39 PM
beanz accepted this revision.Aug 14 2023, 1:08 PM

LGTM. This is definitely an improvement over the awfulness we were doing. Thanks @bogner!

This revision was landed with ongoing or failed builds.Aug 14 2023, 1:27 PM
This revision was automatically updated to reflect the committed changes.
phosek added a subscriber: phosek.Aug 14 2023, 4:51 PM
phosek added inline comments.
llvm/include/llvm/Option/OptParser.td
153

Would it be possible to spell this out in full, that is Visibility rather than Vis? It's more consistent with all other attributes and improves readability in my opinion.

bogner added inline comments.Aug 14 2023, 5:06 PM
llvm/include/llvm/Option/OptParser.td
153

Sure, I can change it. I went with brevity thinking that it would help readability, especially in clang's Options.td, but I'm fairly okay with either way.

bogner marked an inline comment as done.Aug 15 2023, 1:18 AM