[PATCH] D34758: [YAML] - Teach yaml2obj/obj2yaml to work with numeric relocation values.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 01:24:09 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D34758#794033, @ruiu wrote:

> It seems you can do this without modifying YAMLTraits.h. You can set some invalid value (such as -1) to `Value` at beginning of `ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration`  and then check if it still has the invalid value after the switch.


That will work for jaml2obj case, but will not work for case when IO.outputting() == true unfortunately (obj2yaml case).

In the latter case `Value` will have some value read from object. Then IO.enumCase() calls Output::matchEnumScalar(), which sets EnumerationMatchFound to true if enumeration was
matched. This flag can be used to check that we found the enumeration, but it is private and I would prefer not to add accessor for it, its a part of internal implementation 
and too specific thing to provide access to, probably.

That is why I added return value to enumCase instead. It looks more clear for my eye when enumCase() just can say whether it was able to handle the case or not.


https://reviews.llvm.org/D34758





More information about the llvm-commits mailing list