When mapping an optional 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: [[FLAGS=<none>]] ## some comments.
```
the raw value of `ScalarNode` is "<none> " rather than "<none>". We need
to remove the spaces.
Differential Revision: https://reviews.llvm.org/D85180
bool IsNone = false;
if (!outputting())
if (auto *Node = dyn_cast<ScalarNode>(((Input *)this)->getCurrentNode()))
- IsNone = Node->getRawValue() == "<none>";
+ // We use rtrim to ignore possible white spaces that might exist when a
+ // comment is present on the same line.
+ IsNone = Node->getRawValue().rtrim(' ') == "<none>";
if (IsNone)
Val = DefaultValue;
Sections:
- Name: .bar
Type: SHT_PROGBITS
+ Flags: [[TEST=<none>]] ## Comment
Offset: [[TEST=<none>]]
Address: [[TEST=<none>]]
Content: [[TEST=<none>]]