[llvm-dev] llvm::cl::opt and enums

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 31 11:06:49 PDT 2016

I was adding a new option for our backend, and because of the nature of the
option I wanted to use an 'enum', something like:


enum Direction {







cl:opt<Direction> myOpt("option-switch", cl::init(up), cl::desc("what it
does"), cl::Hidden);


This bit is fine, but then I wanted to change it on the command-line to
'clang' and tried:


clang ... -mllvm -option-switch=3 ...

but that doesn't work, and I get something like "invalid option '3'".  If I
change the type to 'int' it works fine.  Is it valid to use an 'enum' in
this way?  And if so, what is the correct way of specifying a value to the
option if I do use an 'enum' for the type?






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160831/6c0ce2fe/attachment.html>

More information about the llvm-dev mailing list