This is an archive of the discontinued LLVM Phabricator instance.

[flang][docs][nfc] Refine FlangOptionsDocs.td
ClosedPublic

Authored by awarzynski on Jul 26 2022, 3:04 AM.

Details

Summary

Currently, FlangOptionsDocs.td doesn't specify ExcludedFlags which
means that in the generated documentation file we expose flags that:

  • we don't necessarily want to advertise to our users (e.g. hidden flags), or
  • are not supported altogether (e.g. CL options).

This patch defines ExcludeFlags to fix that. The definition of
ExcludeFlags was copied from Clang so that LLVM frontends have
consistent documentation.

It might be a bit counter-intuitive that IncludeFlags alone is not sufficient
here. However, the current logic in ClangOptionDocEmitter.cpp will parse
IncludeFlags and print all options that contains one of the included flags,
as well as their aliases. So, for example, for -fopenmp (which is a
supported Flang option), one would also get /fopenmp (i.e. CL mode
equivalent for -fopenmp). By adding ExcludeFlags,. which make sure
that such aliases are excluded.

I've also taken the liberty and moved FlangOptionsDocs.td. Originally it
was located in Flang's top include directory, but there shouldn't be any
implementation/documentation files there. Instead, I'm moving it to the
flang/docs directory.

Diff Detail

Event Timeline

awarzynski created this revision.Jul 26 2022, 3:04 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a subscriber: mgorny. · View Herald Transcript
awarzynski requested review of this revision.Jul 26 2022, 3:04 AM
rovka edited the summary of this revision. (Show Details)Jul 26 2022, 3:30 AM
rovka added a subscriber: rovka.Jul 26 2022, 3:36 AM

This is strange. What does IncludedFlags do, exactly? What happens for instance to FC1Options, do they get included or not?

flang/docs/FlangOptionsDocs.td
36

If you've moved FlangOptionsDocs.td from flang/include/flang/ to flang/docs/, then should this include not be change to "../../clang/include/clang/Driver/Options.td"?

I should've mentioned - it might be helpful to see https://reviews.llvm.org/D129864 for context. This patch is a follow-up.

This is strange.

I agree. This is down to how the logic for "including" and "excluding" option flags works (used when e.g. printing --help). It is not particularly flexible. When Flang was introduced, that became quite apparent (we were missing a good mechanism for making sure that clang --help does not contain Fortran options and that flang-new --help does not contain C++ options). This is closely related.

What does IncludedFlags do, exactly?

See here.

What happens for instance to FC1Options, do they get included or not?

They do not get included as they are not listed in includeFlags.

Note that once IncludedFlags is used, only things on the "include" list are ... included. But that includes option aliases, unless ExcludeFlags is used as well (see here).

awarzynski added inline comments.Jul 26 2022, 8:00 AM
flang/docs/FlangOptionsDocs.td
36

Yes! In fact, this should simply be include "Options.td" and flang/docs/CMakeLists.txt should contain the required include paths. Update coming shortly :)

Update include in FlangOptionsDocs.td

Fix CMake configuration

This revision is now accepted and ready to land.Jul 27 2022, 9:18 AM
rovka added a comment.Jul 28 2022, 4:56 AM

I should've mentioned - it might be helpful to see https://reviews.llvm.org/D129864 for context. This patch is a follow-up.

This is strange.

I agree. This is down to how the logic for "including" and "excluding" option flags works (used when e.g. printing --help). It is not particularly flexible. When Flang was introduced, that became quite apparent (we were missing a good mechanism for making sure that clang --help does not contain Fortran options and that flang-new --help does not contain C++ options). This is closely related.

What does IncludedFlags do, exactly?

See here.

What happens for instance to FC1Options, do they get included or not?

They do not get included as they are not listed in includeFlags.

Note that once IncludedFlags is used, only things on the "include" list are ... included. But that includes option aliases, unless ExcludeFlags is used as well (see here).

Ok, thanks for the explanation! I think I was probably missing the part about option aliases. Could you update the summary to explain a bit more about why unwanted options were being included? For instance, my expectation would be that irrelevant/unsupported options wouldn't be marked as FlangOptions in the first place, and therefore would not be included by default. I think it's worth clarifying this point in the summary.

awarzynski edited the summary of this revision. (Show Details)Jul 29 2022, 1:27 AM

Could you update the summary to explain a bit more about why unwanted options were being included?

Good idea! How about now?

rovka accepted this revision.Aug 1 2022, 5:34 AM

LGTM, thanks! And sorry to keep you waiting!

This revision was automatically updated to reflect the committed changes.