OSDN Git Service

[YAML] Quote multiline string scalars
authorIlya Biryukov <ibiryukov@google.com>
Wed, 30 May 2018 10:40:11 +0000 (10:40 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Wed, 30 May 2018 10:40:11 +0000 (10:40 +0000)
commitcab5faf1e22c36a6ff561001ce830910cee4de76
tree8b4ba071a63fbffcdd456a99ae4eb2d7d2d020f8
parentadcf643e71823ecd2e9abe12b52e5a06c13ac1fd
[YAML] Quote multiline string scalars

Summary:
Otherwise, the YAML parser breaks when trying to read them back in
'key: multiline_string_value' cases.

This patch fixes a problem when serializing structs which contain multi-line strings.
E.g., if we try to serialize  the following struct
```
{ "key1": "first line\nsecond line",
  "key2": "another string" }`
```

Before this patch, we got the YAML output that failed to parse:
```
key1: first line
second line
key2: another string
```

After the patch, we get:
```
key1: 'first line
second line'
key2: another string
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D47468

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333527 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/YAMLTraits.h
unittests/Support/YAMLIOTest.cpp