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

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


Thanks Renato,

Yes, checking it early as a string would work.  Originally I had thought of making the option be a string, but since I need to check it for about 50% of our MachineInstr's, using StringSwitch didn't make sense for performance.  But pre-handling the option like this should work.

All the best,

	MartinO

-----Original Message-----
From: Renato Golin [mailto:renato.golin at linaro.org] 
Sent: 31 August 2016 19:13
To: Martin J. O'Riordan <Martin.ORiordan at movidius.com>
Cc: LLVM Developers <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] llvm::cl::opt and enums

On 31 August 2016 at 19:06, Martin J. O'Riordan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 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?

Try something similar to this:

https://reviews.llvm.org/D24070

cheers,
--renato



More information about the llvm-dev mailing list