[clang-tools-extra] [clang] [libcxx] [compiler-rt] [llvm] [lldb] [flang] [lld] [YAMLParser] Unfold multi-line scalar values (PR #70898)

Scott Linder via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 14:15:38 PST 2023


================
@@ -2030,187 +2030,219 @@ bool Node::failed() const {
 }
 
 StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
-  // TODO: Handle newlines properly. We need to remove leading whitespace.
-  if (Value[0] == '"') { // Double quoted.
-    // Pull off the leading and trailing "s.
-    StringRef UnquotedValue = Value.substr(1, Value.size() - 2);
-    // Search for characters that would require unescaping the value.
-    StringRef::size_type i = UnquotedValue.find_first_of("\\\r\n");
-    if (i != StringRef::npos)
-      return unescapeDoubleQuoted(UnquotedValue, i, Storage);
+  if (Value[0] == '"')
+    return getDoubleQuotedValue(Value, Storage);
+  if (Value[0] == '\'')
+    return getSingleQuotedValue(Value, Storage);
+  return getPlainValue(Value, Storage);
+}
+
+static StringRef
+parseScalarValue(StringRef UnquotedValue, SmallVectorImpl<char> &Storage,
+                 StringRef LookupChars,
----------------
slinder1 wrote:

That "\x0A\x0D" must be a part of `LookupChars` but cannot be handled by `UnescapeCallback` (or at least those characters will never reach the callback) is probably worthy of a comment, as it didn't follow for me immediately upon a first read.

https://github.com/llvm/llvm-project/pull/70898


More information about the cfe-commits mailing list