This is an archive of the discontinued LLVM Phabricator instance.

[clang-tblgen] Automatically document options values
ClosedPublic

Authored by serge-sans-paille on Apr 13 2022, 6:55 AM.

Details

Summary

This is a port of f5c666742f7bb4ae79ec79c8acf61dced4d37cc9 to clang's tablegen.
The code duplication is a bit sad there :-/

Related to https://reviews.llvm.org/D122378

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 6:55 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
serge-sans-paille requested review of this revision.Apr 13 2022, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 6:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thank you for improving the tool :)

cd clang
path/to/clang-tblgen --gen-opt-docs -I ../llvm/include -I include/clang/Driver include/clang/Driver/ClangOptionDocs.td > /tmp/0
nvim -d docs/ClangCommandLineReference.rst /tmp/0

Hope a native speaker (@aaron.ballman @dexonsmith @jhenderson ) can suggest the usage here.

For an option with more than 2 choices: the current documentation is <arg> can be one of 'return', 'branch', 'full' or 'none',
I'm thinking of: <arg> should be 'return', 'branch', 'full', or 'none'

When there are two choices (-gsplit-dwarf=<arg>), currently the documentation is <arg> can be one of 'split' or 'single'.
I am thinking of <arg> should be 'split' or 'single'.

clang/utils/TableGen/ClangOptionDocEmitter.cpp
241

constexpr StringLiteral

const variable at a namespace scope is automatically internal linkage, except some weird corner cases.

aaron.ballman accepted this revision.Apr 14 2022, 6:20 AM

Thank you for improving the tool :)

cd clang
path/to/clang-tblgen --gen-opt-docs -I ../llvm/include -I include/clang/Driver include/clang/Driver/ClangOptionDocs.td > /tmp/0
nvim -d docs/ClangCommandLineReference.rst /tmp/0

Hope a native speaker (@aaron.ballman @dexonsmith @jhenderson ) can suggest the usage here.

For an option with more than 2 choices: the current documentation is <arg> can be one of 'return', 'branch', 'full' or 'none',
I'm thinking of: <arg> should be 'return', 'branch', 'full', or 'none'

When there are two choices (-gsplit-dwarf=<arg>), currently the documentation is <arg> can be one of 'split' or 'single'.
I am thinking of <arg> should be 'split' or 'single'.

Both of these suggestions seem reasonable to me (shorter but equally as clear as before), but we should fix to be consistent in llvm/utils/TableGen/OptRSTEmitter.cpp if we opt to go this route.

The changes here LGTM as-is (I'm happy with either current wording or the changed wording). Thanks for this!

This revision is now accepted and ready to land.Apr 14 2022, 6:20 AM

@aaron.ballman Any thoughs on the above suggestion? I'd be happy to adopt any of those :-)

@aaron.ballman Any thoughs on the above suggestion? I'd be happy to adopt any of those :-)

I'd go with:

More than two choices: <arg> should be 'return', 'branch', 'full', or 'none'
Only two choices: <arg> should be 'split' or 'single'.

@aaron.ballman Any thoughs on the above suggestion? I'd be happy to adopt any of those :-)

I'd go with:

More than two choices: <arg> should be 'return', 'branch', 'full', or 'none'
Only two choices: <arg> should be 'split' or 'single'.

FWIW, I'd actually use "must" rather than "should", but otherwise I agree with this. "should" implies there are cases where it is okay to use a different value, which is obviously not the intent.

serge-sans-paille marked an inline comment as done.

Adopt a better wording.

Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 6:32 AM
This revision was landed with ongoing or failed builds.Apr 20 2022, 1:00 PM
This revision was automatically updated to reflect the committed changes.