[llvm-dev] ArgList flag values

via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 10 08:31:16 PDT 2018



> -----Original Message-----
> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of David
> Greene via llvm-dev
> Sent: Thursday, August 09, 2018 5:28 PM
> To: llvm-dev at lists.llvm.org
> Subject: [llvm-dev] ArgList flag values
> 
> I've come across a need to know whether an option was set true, false or
> unspecified.  If it is true I want to do one thing, if it is false I
> want to do something else and if it is unspecified I want to do nothing.
> 
> ArgList::hasFlag is a convenient way to check true/false with a default
> value.  An ArgList::hasFlag that returned Optional<bool> would allow
> checking the unspecified case.  Returning some kind Tribool class object
> would allow the same.
> 
> Both Optional<bool> and Tribool are somewhat overkill for this kind of
> thing as I really wouldn't need to do comparisons and logical operations
> on the value.  A three-state enum (class) would do just as well.
> 
> Is there an existing way to handle this kind of flag?  If not, would
> there be interest in adding support for it?

I'd be inclined to use getLastArg for this, which returns nullptr if you
don't have any of the specified options.
--paulr

> 
>                          -David
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list