[PATCH] D39908: Allow empty mappings for optional YAML input

Dave Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 09:47:39 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL318428: Allow empty mappings for optional YAML input (authored by kastiglione).

Repository:
  rL LLVM

https://reviews.llvm.org/D39908

Files:
  llvm/trunk/lib/Support/YAMLTraits.cpp
  llvm/trunk/test/tools/yaml2obj/empty-symbols.yaml


Index: llvm/trunk/test/tools/yaml2obj/empty-symbols.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/empty-symbols.yaml
+++ llvm/trunk/test/tools/yaml2obj/empty-symbols.yaml
@@ -0,0 +1,10 @@
+# Ensure yaml2obj doesn't error on empty optional mappings, such as Symbols
+# RUN: yaml2obj %s -o %t
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_X86_64
+Symbols:
Index: llvm/trunk/lib/Support/YAMLTraits.cpp
===================================================================
--- llvm/trunk/lib/Support/YAMLTraits.cpp
+++ llvm/trunk/lib/Support/YAMLTraits.cpp
@@ -160,7 +160,8 @@
 
   MapHNode *MN = dyn_cast<MapHNode>(CurrentNode);
   if (!MN) {
-    setError(CurrentNode, "not a mapping");
+    if (Required || !isa<EmptyHNode>(CurrentNode))
+      setError(CurrentNode, "not a mapping");
     return false;
   }
   MN->ValidKeys.push_back(Key);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39908.123200.patch
Type: text/x-patch
Size: 989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171116/b344a401/attachment.bin>


More information about the llvm-commits mailing list