[llvm-dev] 'cl::opt' and range checking
ORiordan, Martin via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 4 01:42:17 PDT 2017
Thanks Zachary,
That’s seems like the best approach; it is certainly useful from time-to-time and makes sense that checking for out-of-range is in a shared reusable component.
All the best,
MartinO
From: Zachary Turner [mailto:zturner at google.com]
Sent: Wednesday, October 4, 2017 4:55 AM
To: ORiordan, Martin <martin.oriordan at intel.com>; llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] 'cl::opt' and range checking
I don't think this is currently supported by `cl::opt`, but you can probably write your own adapter class so that you could write `cl::opt<cl::range<int,3,7>>`.
You'd just need to write a parser for `cl::range` and do the checking in there. Seems like a useful patch, I've needed this from time to time myself.
On Tue, Oct 3, 2017 at 6:24 AM ORiordan, Martin via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:
Hi LLVM-Devs,
The LLVM ‘cl::opt’ templates are really useful, and provide a lot of flexibility. But I don’t see any support for ranged options. What I would like is to have an option which is an integer type, and to restrict the set of values provided to a simple upper and lower bound, for example between 10 and 2000.
Is there a way of expressing this with the ‘cl::opt’ templates, or do I have to explicitly range check the values in my own code and issue a diagnostic or clamp as appropriate?
Thanks,
MartinO
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171004/712826a6/attachment.html>
More information about the llvm-dev
mailing list