diff options
author | Dmitry Polukhin <dmitry.polukhin@gmail.com> | 2020-05-20 08:06:41 -0700 |
---|---|---|
committer | Dmitry Polukhin <dmitry.polukhin@gmail.com> | 2020-07-09 02:41:58 -0700 |
commit | 9e7fddbd36f567217255c1df1cb816b79f0250af (patch) | |
tree | b8e1fc85aa316d196988be2fab07c6a30a4e3c69 /llvm/lib/Support/YAMLTraits.cpp | |
parent | [mlir] Add additional Canonicalization of shape.cstr_broadcastable. (diff) | |
download | llvm-project-9e7fddbd36f567217255c1df1cb816b79f0250af.tar.gz llvm-project-9e7fddbd36f567217255c1df1cb816b79f0250af.tar.bz2 llvm-project-9e7fddbd36f567217255c1df1cb816b79f0250af.zip |
[yaml][clang-tidy] Fix multiline YAML serialization
Summary:
New line duplication logic introduced in https://reviews.llvm.org/D63482
has two issues: (1) there is no logic that removes duplicate newlines
when clang-apply-replacment reads YAML and (2) in general such logic
should be applied to all strings and should happen on string
serialization level instead in YAML parser.
This diff changes multiline strings quotation from single quote `'` to
double `"`. It solves problems with internal newlines because now they are
escaped. Also double quotation solves the problem with leading whitespace after
newline. In case of single quotation YAML parsers should remove leading
whitespace according to specification. In case of double quotation these
leading are internal space and they are preserved. There is no way to
instruct YAML parsers to preserve leading whitespaces after newline so
double quotation is the only viable option that solves all problems at
once.
Test Plan: check-all
Reviewers: gribozavr, mgehre, yvvan
Subscribers: xazax.hun, hiraditya, cfe-commits, llvm-commits
Tags: #clang-tools-extra, #clang, #llvm
Differential Revision: https://reviews.llvm.org/D80301
Diffstat (limited to 'llvm/lib/Support/YAMLTraits.cpp')
-rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index 752fab2be9b3..9ac7c65e19f7 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -878,12 +878,12 @@ StringRef ScalarTraits<StringRef>::input(StringRef Scalar, void *, } void ScalarTraits<std::string>::output(const std::string &Val, void *, - raw_ostream &Out) { + raw_ostream &Out) { Out << Val; } StringRef ScalarTraits<std::string>::input(StringRef Scalar, void *, - std::string &Val) { + std::string &Val) { Val = Scalar.str(); return StringRef(); } |