[cfe-dev] Help with Command-Line Validation

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 24 09:39:31 PST 2015


On Tue, Nov 24, 2015 at 8:47 AM, Uri Mann via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I’m updating from CLANG 3.5.0 to 3.7.0. In the 3.5.0 version I have a
> std::string option with validation.
>
> struct ProjectParser : public llvm::cl::parser<std::string> {
>
>     bool parse(llvm::cl::Option& option,
>
>                           llvm::StringRef argName,
>
>                           const std::string& argValue,
>
>                           std::string& project);
>
> };
>
>
>
> llvm::cl::opt<std::string, false, ProjectParser> Project;
>
>
>
> This no longer compiles since the llvm::cl::parser<std::string> template
> was specialized and made ‘final’. The docs don’t address this issue.
>

Sorry about that - I've an open bug telling me I need to update the docs
here. I made the change to make parser final (bunch of API design reasons
and that extension point wasn't needed inside LLVM/Clang - though I didn't
realize we documented it as an extension point for external users)

I'm not quite sure why we documented this as a useful extension point for
external users yet have no examples of using that inside the LLVM project -
I imagine we do something else inside LLVM instead.

Off the cuff, I would suggest you derived from basic_parser and add the two
member typedefs that parser<T> was providing for you. (but I'm still
curious what LLVM does if it doesn't do the derivation from parser<T> and
whether we should understand/encourage that instead)

- Dave


>
>
> Any help will be appreciated. Thanks in advance.
>
> -Uri
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151124/dc3c752f/attachment.html>


More information about the cfe-dev mailing list