<div dir="ltr">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>>`.<div><br></div><div>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.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 3, 2017 at 6:24 AM ORiordan, Martin via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-IE" link="#0563C1" vlink="#954F72">
<div class="m_4962087040259976941WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Hi LLVM-Devs,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">The LLVM ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">cl::opt</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ 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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Is there a way of expressing this with the ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">cl::opt</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’
 templates, or do I have to explicitly range check the values in my own code and issue a diagnostic or clamp as appropriate?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">            MartinO<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p>
</div>
<p>--------------------------------------------------------------<br>
Intel Research and Development Ireland Limited<br>
Registered in Ireland<br>
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare<br>
Registered Number: 308263</p>


<p>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.</p>

<p></p>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>