Support's Command Line API -- custom parsers for fundamental types

Christoph Kindl via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 08:17:32 PST 2017


Dear LLVM-Developers,
Dear LLVM-Community,

I lately stumbled upon the bug #25104 while I wanted to create a custom parser for a cl::opt<float> command line option. Since cl::parser<T> implementations were marked final in 3.7, it is no longer possible to derive from them. Deriving from cl::basic_parser<T> for fundamental types is not possible either, causing a compiler error (cf. https://bugs.llvm.org/show_bug.cgi?id=25104#c3). Therefore, I want to provide a small patch which allows to derive from cl::basic_parser<T> for fundamental types again.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: basic_parser-ckristo-20171221.patch
Type: application/octet-stream
Size: 8716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171221/2a600047/attachment.obj>
-------------- next part --------------


Please note that this patch does not allow to build upon existing parsers again (as prev. possible by inheriting from cl::parser<T>), i.e. a custom parser for a numeric option which just wants to check if the option is in a given range e.g. must reimplement number parsing. This is not ideal, I know, but I do not have an idea how to make this easily possible again without removing final from cl::parser<T>. Any ideas?

I kindly ask for review. Be warned though: this is my first patch for LLVM :-)

Best regards,
Christoph

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171221/2a600047/attachment.bin>


More information about the llvm-commits mailing list