[PATCH] [lld] enable mach-o and native yaml to be intermixed

kledzik at apple.com kledzik at apple.com
Thu Jan 9 15:48:54 PST 2014



================
Comment at: lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp:306-309
@@ -302,1 +305,6 @@
+      uint8_t *bytes = file->ownedAllocations.Allocate<uint8_t>(size);
+      uint8_t *p = bytes;
+      for (Hex8 &byte : _normalizedContent) {
+        *p++ = byte;
       }
+      return makeArrayRef(bytes, size);
----------------
Shankar Kalpathi Easwaran wrote:
> wouldnt memcpy work here ?
The source is a Hex8 array, the destination is uint8_t array.  Pragmatically, a memcpy() would  work, but some language lawyers would think it fragile. 

================
Comment at: lib/ReaderWriter/YAML/ReaderWriterYAML.cpp:1307
@@ -1286,2 +1306,3 @@
+                                    new ArchiveYamlIOTaggedDocumentHandler()));
 }
 
----------------
Shankar Kalpathi Easwaran wrote:
> We would require the yaml reader to parse macho yaml tags too right ?
The base yaml reader only supports !native and !archive tags.  You have to use addSupportMachOObjects() to get !mach-o tag support.

================
Comment at: lib/ReaderWriter/YAML/ReaderWriterYAML.cpp:670-671
@@ +669,4 @@
+    // Let any register tag handler process this.
+    if (info->_registry && info->_registry->handleTaggedDoc(io, file))
+        return;
+    // If no registered handler claims this tag and there is no tag, 
----------------
Shankar Kalpathi Easwaran wrote:
> If there is an error while parsing the document we may want to return the error, possibly mapping should return an error_code ?
The way YAML I/O works is that the io object has the the error_code which is checked at the end via "if (yin.error())".  

================
Comment at: include/lld/ReaderWriter/Reader.h:82
@@ +81,3 @@
+  /// YAML I/O, then convert the result into an lld::File* and return it.
+  virtual bool handledDocTag(llvm::yaml::IO &io, const lld::File *&f) const = 0;
+};
----------------
Shankar Kalpathi Easwaran wrote:
> Does this need to be handleDocTag ?
I made it "handledDocTag" (note extra 'd') so it read well in an if statement:
  if (handledDocTag(..))
     return;
It returns false if it did not handle the tag.



http://llvm-reviews.chandlerc.com/D2529

BRANCH
  svn

ARCANIST PROJECT
  lld



More information about the llvm-commits mailing list