[PATCH] D23766: DebugInfo: introduce DIFlagsUnderlying type for debug info flags

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 11:44:14 PDT 2016


See llvm/include/llvm/ADT/BitmaskEnum.h 

> On Aug 29, 2016, at 11:35 AM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> Justin - didn't you, or someone, play around with making a utility for enums that represent flags to work more betterer?
> 
> On Mon, Aug 29, 2016 at 11:31 AM Victor <vleschuk at gmail.com <mailto:vleschuk at gmail.com>> wrote:
> vleschuk added a comment.
> 
> In https://reviews.llvm.org/D23766#528004 <https://reviews.llvm.org/D23766#528004>, @dblaikie wrote:
> 
> > Why is it that we aren't just using teh DIFlags type directly everywhere we are currently using unsigned (everywhere you're changing to DIFlagsUnderlying)?
> 
> 
> Because constructions like the following do not compile
> 
>   enum DIFlags: uint32_t
>   {
>       Flag1 = 1,
>       Flag2 = 1 << 2,
>       Flag3 = 1 << 3,
>   };
> 
>   // ....
> 
>   DIFlags Flags = Flag1 | Flag2; // expression (Flag1 | Flag2) isn't DIFlags, it results in underlying type
> 
> 
> 
>   clang++ -std=c++11 t.cpp -o t
>   t.cpp:12:13: error: cannot initialize a variable of type 'DIFlags' with an rvalue of type 'unsigned int'
>       DIFlags Flags = Flag1 | Flag2;
>               ^       ~~~~~~~~~~~~~
>   1 error generated.
> 
> 
> https://reviews.llvm.org/D23766 <https://reviews.llvm.org/D23766>
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160829/c78fcc80/attachment.html>


More information about the llvm-commits mailing list