[llvm-dev] ArgList flag values
David Greene via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 9 14:28:13 PDT 2018
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?
-David
More information about the llvm-dev
mailing list