[PATCH] D85180: [YAMLTraits] Fix mapping <none> value that followed by comments.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 00:26:57 PDT 2020
Higuoxing created this revision.
Higuoxing added reviewers: grimar, jhenderson, MaskRay.
Herald added subscribers: llvm-commits, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Higuoxing requested review of this revision.
When mapping an optional `ScalarBitSetTraits` value, if the value is
<none> and followed by comments, there will be a parsing error. This
patch helps fix this issue.
e.g.,
When mapping the following YAML,
Sections:
- Name: blah
Type: SHT_foo
Flags: <none> ## some comments.
the raw value of `Scalarnode` is "<none> " rather than "<none>". We need
to remove the spaces.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85180
Files:
llvm/include/llvm/Support/YAMLTraits.h
llvm/test/tools/yaml2obj/ELF/none-value.yaml
Index: llvm/test/tools/yaml2obj/ELF/none-value.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/none-value.yaml
+++ llvm/test/tools/yaml2obj/ELF/none-value.yaml
@@ -21,6 +21,7 @@
Sections:
- Name: .bar
Type: SHT_PROGBITS
+ Flags: [[TEST=<none>]] ## Comment
Offset: [[TEST=<none>]]
Address: [[TEST=<none>]]
Content: [[TEST=<none>]]
Index: llvm/include/llvm/Support/YAMLTraits.h
===================================================================
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -1629,7 +1629,7 @@
bool IsNone = false;
if (!outputting())
if (auto *Node = dyn_cast<ScalarNode>(((Input *)this)->getCurrentNode()))
- IsNone = Node->getRawValue() == "<none>";
+ IsNone = Node->getRawValue().trim() == "<none>";
if (IsNone)
Val = DefaultValue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85180.282813.patch
Type: text/x-patch
Size: 962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200804/6ea00cf2/attachment.bin>
More information about the llvm-commits
mailing list