[PATCH] D39908: Allow empty mappings for optional YAML input
Dave Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 23:42:36 PST 2017
kastiglione updated this revision to Diff 123133.
kastiglione added a comment.
inline if condition
https://reviews.llvm.org/D39908
Files:
lib/Support/YAMLTraits.cpp
test/tools/yaml2obj/empty-symbols.yaml
Index: test/tools/yaml2obj/empty-symbols.yaml
===================================================================
--- /dev/null
+++ 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: lib/Support/YAMLTraits.cpp
===================================================================
--- lib/Support/YAMLTraits.cpp
+++ 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.123133.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171116/60aa97de/attachment.bin>
More information about the llvm-commits
mailing list