[LLVMdev] Status of YAML IO?

Nick Kledzik kledzik at apple.com
Wed Oct 24 18:34:24 PDT 2012

On Oct 22, 2012, at 5:07 PM, Nick Kledzik wrote:
> On Oct 22, 2012, at 4:40 PM, Sean Silva wrote:
>> Hey Nick, what's the status on YAML IO? The other thread seems to have died.
> I'm waiting on Michael Spencer's feedback.  

To better understand how a client would use YAML I/O.  I've completely rewritten the ReaderYAML and WriterYAML in lld to use YAML I/O.  The source code is now about half the size.  But more importantly,  the error checking is much, much better and any time an attribute (e.g. of an Atom) is changed or added, there is just one place to update the yaml code instead of two places (the reader and writer).  

This code requires no changes to the rest of lld.  The traits based approach was thus non-invasive.  It is able to produce yaml from existing data structures and when reading yaml recreate the existing data structures.

The example also shows how context sensitive yaml conversion is done, using io.getContext() to make conversion decisions.

The StringRef ownership works, but is a little clunky.  Because one yaml stream can contain many documents, the ownership of the input file MemoryBuffer cannot be handed off to the newly created lld::File object (which would have allowed any StringRefs provided by the parse to be used as is).  Instead whenever a trait needs to keep a StringRef it must make a copy of the underlying string, and the copies are owned by  the generated lld::File object.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReaderWriterYAML.cpp
Type: application/octet-stream
Size: 42575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121024/90283f3f/attachment.obj>
-------------- next part --------------


More information about the llvm-dev mailing list