Is there precedent for customizing clang -help output in a toolchain specific way

Hi All,

I am looking to customize the -help display for a downstream clang port as many options defined in Options.td are not applicable to the processor family I’m targeting and several applicable options do not have HelpText.

I’ve considered adding a toolchain specific hook in the vicinity of Driver::PrintHelp(), but I’d rather avoid adding a hook if there is a better solution that already exists.

Is there a best practice for enabling a toolchain to control the output of the clang –help option?

~ Todd Snider

[+ cfe-dev]

Hi Todd,

We're currently trying to solve a similar problem for Flang [1]. From what we have seen so far,

* Options.td
* the only instance of DriverOptTable [2]
* the ID enum from clang/include/clang/Driver/Options.h [3]

are tightly coupled together and hence it is tricky to pick and choose what you want.

There's also getIncludeExcludeOptionFlagMasks in clang/lib/Driver/Driver.cpp [4], but I'm confused about the meaning of IncludedFlagsBitmask and ExcludedFlagsBitmask. We did experiment with that, but that made libclangDriver quite unhappy (things started to break in an unexpected way).

Perhaps somebody on cfe-dev (CC'ed) would have some hints? In the meantime we've also been customising Driver::PrintHelp().

-Andrzej

[1] http://lists.llvm.org/pipermail/llvm-dev/2020-June/141994.html
[2] llvm-project/DriverOptions.cpp at 2c1799f8928e1a63020fa8099d254c084f8be2f2 · llvm/llvm-project · GitHub
[3] llvm-project/Options.h at 2c1799f8928e1a63020fa8099d254c084f8be2f2 · llvm/llvm-project · GitHub
[4] llvm-project/Options.h at 2c1799f8928e1a63020fa8099d254c084f8be2f2 · llvm/llvm-project · GitHub