This is an archive of the discontinued LLVM Phabricator instance.

[OptTable] Refine how `printHelp` treats empty help texts
ClosedPublic

Authored by awarzynski on Aug 5 2021, 4:50 AM.

Details

Summary

Currently, printHelp behaves differently for options that:

  • do not define HelpText (such options _are not_ printed), and
  • define its HelpText as HelpText<""> (such options _are_ printed).

In practice, both approaches lead to no help text and printHelp should
treat them consistently. This patch addresses that by making
printHelpt check the length of the help text to be printed.

Diff Detail

Event Timeline

awarzynski created this revision.Aug 5 2021, 4:50 AM
awarzynski requested review of this revision.Aug 5 2021, 4:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2021, 4:50 AM

With this change, llvm/test/tools/llvm-cvtres/help.tes is failing. That's because the help text in llvm-cvtres relies on the old behavior. The corresponding *.td file is tiny and perhaps @thakis or @mstorsjo could suggest how to update it?

jansvoboda11 accepted this revision.Aug 5 2021, 7:26 AM

This LGTM provided we figure out what to about llvm-cvtres.

This revision is now accepted and ready to land.Aug 5 2021, 7:26 AM

With this change, llvm/test/tools/llvm-cvtres/help.tes is failing. That's because the help text in llvm-cvtres relies on the old behavior. The corresponding *.td file is tiny and perhaps @thakis or @mstorsjo could suggest how to update it?

Hmm, that's a good question. Most of the options that are listed aren't even hooked up in llvm-cvtres (and the tool it impersonates, MS cvtres.exe, also just lists the options by name without any help text in its help printing).

I guess we could add a help text for the options that we have implemented at least, and then omit the other ones. Or do @thakis or @amccarth have a strong opinion on it?

Hmm, that's a good question. Most of the options that are listed aren't even hooked up in llvm-cvtres (and the tool it impersonates, MS cvtres.exe, also just lists the options by name without any help text in its help printing).

I guess we could add a help text for the options that we have implemented at least, and then omit the other ones. Or do @thakis or @amccarth have a strong opinion on it?

I don't have a strong opinion either way. If a tool accepts an option, I'd prefer to see it listed. If these options don't have help text because the tool is ignoring the option (but allowing it for compatibility), then I'd suggest we add some help text that says something to that effect, like "not implemented."

With clang-cl /?, I see /Og as "no effect". There are also a few described as "Deprecated, <original purpose>".

@thakis may have stronger opinions on this than I do.

Add help text to all options in llvm-cvtres

I've tried to come up with something sensible for every option. As suggested by @amccarth, options that are not implemented get "Not implemented".

Thank you for reviewing!

Hi, I believe that I've addressed all of your comments and would like to merge this. I will be away starting from next week and want to make sure that this doesn't become stale.

Please leave a comment if you feel that this is not ready. Otherwise, I will merge this before the end of the week. Thank you for all your comments!

FWIW, the change looks sensible to me.