[PATCH] [YAML] Add an optional argument `EnumMask` to the `yaml::IO::bitSetCase()`
kledzik at apple.com
kledzik at apple.com
Wed May 21 14:07:45 PDT 2014
Please update the yaml documentation (llvm/docs/YamlIO.rst) with this new functionality too.
BTW, I had this same issue with mach-o in which the uint32_t section "flags" field has a 8-bit enum and 24-bits of flags. What I did was break them into two yaml fields.
================
Comment at: include/llvm/Support/YAMLTraits.h:475-483
@@ -474,8 +474,11 @@
template <typename T>
- void bitSetCase(T &Val, const char* Str, const T ConstVal) {
- if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
+ void bitSetCase(T &Val, const char *Str, const T ConstVal,
+ const T EnumMask = T(0)) {
+ bool Match = (EnumMask && (Val & EnumMask) == ConstVal) ||
+ (!EnumMask && (Val & ConstVal) == ConstVal);
+ if (bitSetMatch(Str, outputting() && Match)) {
Val = Val | ConstVal;
}
}
----------------
I think it would be cleaner to add a new method:
void maskedBitSetCase()
or
void bitSetCaseWithMask()
rather that adding that optional parameter, because now you have to check if the mask is zero (not used) and use different bit checking.
http://reviews.llvm.org/D3807
More information about the llvm-commits
mailing list