[PATCH] D23766: DebugInfo: use strongly typed enum for debug info flags

Victor via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 14:24:57 PDT 2016


vleschuk added inline comments.

================
Comment at: include/llvm/IR/DebugInfoMetadata.h:183
@@ -180,2 +182,3 @@
   };
+  typedef std::underlying_type<DIFlags>::type DIFlagsUnderlying;
 
----------------
dblaikie wrote:
> I'm assuming we don't need DIFlagsUnderlying anymore? Can we just use DIFlags everywhere?
Nope. For example see updated ::get definitions in classes derived from DINode:


```
DEFINE_MDNODE_GET(DIDerivedType,
                    (unsigned Tag, MDString *Name, Metadata *File,
                     unsigned Line, Metadata *Scope, Metadata *BaseType,
                     uint64_t SizeInBits, uint64_t AlignInBits,
                     uint64_t OffsetInBits, **DIFlagsUnderlying** Flags,
                     Metadata *ExtraData = nullptr),
                    (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
                     AlignInBits, OffsetInBits, **static_cast<DIFlags>(Flags)**, ExtraData))
```

This helps to avoid lots of static_casts in client code. Also some utility functions like splitFlags require this underlying type to process bitmasks which can consist not only of enumerated flags. 

In other words, this typedef is used in order not to break old code and avoid lots of code rewriting.


https://reviews.llvm.org/D23766





More information about the llvm-commits mailing list