Details
- Reviewers
jhenderson haowei MaskRay - Commits
- rG480dcdc8975d: [ifs] Switch to using OptTable
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I've added @MaskRay as he's done a number of cl::opt -> OptTable transitions in other tools.
One thing I haven't done yet is ensure that all old options are still present in the new tool. A task for later (or someone else).
llvm/tools/llvm-ifs/Opts.td | ||
---|---|---|
12 | I'd generally put these options in alphabetical order, to make it easier to find options. | |
38 | Let's normalise the help text whilst we're here (i.e. no trailing full stop). | |
llvm/tools/llvm-ifs/llvm-ifs.cpp | ||
95–101 | Aphabetical order within these groups would make sense, I think. | |
316 | Should this have a std::exit(1) after it? Also, I believe you should be using WithColor::error() like other error reporting? Same as others below. Perhaps worth factoring out error reporting into a different function to ensure bits like that aren't missed. | |
327–328 | Also applies to other similar cases. | |
336 |
| |
350–353 | This needs an error if an invalid option is specified (and a corresponding test case). Otherwise --endianness=foo will be accepted. | |
527–529 | Code like this shows more need for a noreturn error function, to save weirdness like inconsistent return values. May also be worth a separate patch bringing all error messages into line with https://llvm.org/docs/CodingStandards.html#error-and-warning-messages. |
Thanks for the patch. User-facing tools are better using llvm::OptTable. I've only spot one thing other than what has been mentioned.
llvm/tools/llvm-ifs/Opts.td | ||
---|---|---|
34 | --o looks a bit weird. The convention for short options is -o. You may need to check whether your downstream uses --o and removes the usage. It's fine to support both - and -- for now and remove -- later. |
Shouldn't this be covered by tests?
llvm/tools/llvm-ifs/Opts.td | ||
---|---|---|
34 | Thanks good catch, that was just my mistake no one is using that. | |
llvm/tools/llvm-ifs/llvm-ifs.cpp | ||
327–328 | I did it this way to match what llvm::cl errors looked like, and keep the tests the same. WDYT about fixing these errors and others to be more in line with https://llvm.org/docs/CodingStandards.html#error-and-warning-messages in a separate patch? | |
527–529 | Indeed, I will more the errors not added by this patch to use the fatalError overload I added in a separate patch. |
I'd generally put these options in alphabetical order, to make it easier to find options.