[llvm-branch-commits] [llvm] fix: added to fix compile error (PR #67217)
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/67217 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] fix: added to fix compile error (PR #67217)
llvm-beanz wrote: Hi @isubasinghe, as you guessed LLVM 9 is a closed release so we're not accepting PRs into it anymore (even ones that fix pretty obvious issues). Thank you for your contribution (even though we won't be merging it). https://github.com/llvm/llvm-project/pull/67217 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 30fbba9 - [ππ½πΏ] initial version
Author: Scott Linder Date: 2023-11-08T21:05:35Z New Revision: 30fbba91ce82b68395b0b527ff0f34d349e6a010 URL: https://github.com/llvm/llvm-project/commit/30fbba91ce82b68395b0b527ff0f34d349e6a010 DIFF: https://github.com/llvm/llvm-project/commit/30fbba91ce82b68395b0b527ff0f34d349e6a010.diff LOG: [ππ½πΏ] initial version Created using spr 1.3.6-beta.1 Added: Modified: llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp Removed: diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp index 55a0afcf7a33f16..dab27d209d18fd6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -466,9 +466,6 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF, for (const auto &MI : MBB) { if (MI.isDebugValue()) { assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!"); -// Use the base variable (without any DW_OP_piece expressions) -// as index into History. The full variables including the -// piece expressions are attached to the MI. const DILocalVariable *RawVar = MI.getDebugVariable(); assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && "Expected inlined-at fields to agree"); @@ -492,8 +489,7 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF, if (MI.isMetaInstruction()) continue; - // Not a DBG_VALUE instruction. It may clobber registers which describe - // some variables. + // Other instruction may clobber registers which describe some variables. for (const MachineOperand &MO : MI.operands()) { if (MO.isReg() && MO.isDef() && MO.getReg()) { // Ignore call instructions that claim to clobber SP. The AArch64 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 28e8baf - [ππ½πΏ] initial version
Author: Scott Linder Date: 2023-11-08T21:05:40Z New Revision: 28e8baf03efd7ba43a2af4afb3831caa511880ca URL: https://github.com/llvm/llvm-project/commit/28e8baf03efd7ba43a2af4afb3831caa511880ca DIFF: https://github.com/llvm/llvm-project/commit/28e8baf03efd7ba43a2af4afb3831caa511880ca.diff LOG: [ππ½πΏ] initial version Created using spr 1.3.6-beta.1 Added: Modified: llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp Removed: diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp index 55a0afcf7a33f16..8b67580b9ba50b0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -373,6 +373,18 @@ static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV, DbgValueHistoryMap &HistMap) { EntryIndex NewIndex; if (HistMap.startDbgValue(Var, DV, NewIndex)) { +// As we already need to iterate all LiveEntries when handling a DbgValue, +// we use this map to avoid a more expensive check against RegVars. There +// is an assert that we handle this correclty in addRegDescribedVar. +// +// In other terms, the presense in this map indicates the presense of a +// corresponding entry in RegVars. +// +// The bool value then tracks whether an entry is to be retained (true) or +// removed (false); as we end previous entries we speculatively assume they +// can be dropped from RegVars, but we then also visit the new entry whose +// set of debug register operands may overlap and "save" a reg from being +// dropped. SmallDenseMap TrackedRegs; // If we have created a new debug value entry, close all preceding @@ -466,9 +478,6 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF, for (const auto &MI : MBB) { if (MI.isDebugValue()) { assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!"); -// Use the base variable (without any DW_OP_piece expressions) -// as index into History. The full variables including the -// piece expressions are attached to the MI. const DILocalVariable *RawVar = MI.getDebugVariable(); assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && "Expected inlined-at fields to agree"); @@ -492,8 +501,7 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF, if (MI.isMetaInstruction()) continue; - // Not a DBG_VALUE instruction. It may clobber registers which describe - // some variables. + // Other instruction may clobber registers which describe some variables. for (const MachineOperand &MO : MI.operands()) { if (MO.isReg() && MO.isDef() && MO.getReg()) { // Ignore call instructions that claim to clobber SP. The AArch64 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [NFC][AsmPrinter] Clarify handleNewDebugValue cache of TrackedRegs (PR #71737)
https://github.com/slinder1 created https://github.com/llvm/llvm-project/pull/71737 None ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 5784f20 - [YAMLParser] Enable tests for flow scalar styles
Author: Igor Kudrin Date: 2023-11-08T19:20:14-08:00 New Revision: 5784f2014981cdd16095e737d1d128a2995a3dbd URL: https://github.com/llvm/llvm-project/commit/5784f2014981cdd16095e737d1d128a2995a3dbd DIFF: https://github.com/llvm/llvm-project/commit/5784f2014981cdd16095e737d1d128a2995a3dbd.diff LOG: [YAMLParser] Enable tests for flow scalar styles This is a preparing commit for #70898. It activates checks in tests for single-quoted, double-quoted, and plain values and demonstrates how they are handled currently. Added: llvm/test/YAMLParser/spec1.2-07-05.test llvm/test/YAMLParser/spec1.2-07-06.test llvm/test/YAMLParser/spec1.2-07-09.test llvm/test/YAMLParser/spec1.2-07-12.test Modified: llvm/test/YAMLParser/spec-02-17.test llvm/test/YAMLParser/spec-05-13.test llvm/test/YAMLParser/spec-05-14.test llvm/test/YAMLParser/spec-09-01.test llvm/test/YAMLParser/spec-09-02.test llvm/test/YAMLParser/spec-09-03.test llvm/test/YAMLParser/spec-09-04.test llvm/test/YAMLParser/spec-09-05.test llvm/test/YAMLParser/spec-09-06.test llvm/test/YAMLParser/spec-09-07.test llvm/test/YAMLParser/spec-09-08.test llvm/test/YAMLParser/spec-09-09.test llvm/test/YAMLParser/spec-09-10.test llvm/test/YAMLParser/spec-09-11.test llvm/test/YAMLParser/spec-09-13.test llvm/test/YAMLParser/spec-09-16.test llvm/test/YAMLParser/spec-09-17.test llvm/test/YAMLParser/spec-10-02.test Removed: diff --git a/llvm/test/YAMLParser/spec-02-17.test b/llvm/test/YAMLParser/spec-02-17.test index 2bcb60c8d933bd8..e7b0147a0fcd89f 100644 --- a/llvm/test/YAMLParser/spec-02-17.test +++ b/llvm/test/YAMLParser/spec-02-17.test @@ -1,4 +1,4 @@ -# RUN: yaml-bench -canonical %s +# RUN: yaml-bench -canonical %s | FileCheck %s unicode: "Sosa did fine.\u263A" control: "\b1998\t1999\t2000\n" diff --git a/llvm/test/YAMLParser/spec-05-13.test b/llvm/test/YAMLParser/spec-05-13.test index db62e866a755a32..e7ec42a4aaa80d7 100644 --- a/llvm/test/YAMLParser/spec-05-13.test +++ b/llvm/test/YAMLParser/spec-05-13.test @@ -1,4 +1,5 @@ -# RUN: yaml-bench -canonical %s +# RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace +# CHECK: "Text containing \n both space and\t\n \ttab\tcharacters" "Text containing both space and diff --git a/llvm/test/YAMLParser/spec-05-14.test b/llvm/test/YAMLParser/spec-05-14.test index 65451651b69e96b..984f3721312ab63 100644 --- a/llvm/test/YAMLParser/spec-05-14.test +++ b/llvm/test/YAMLParser/spec-05-14.test @@ -1,4 +1,4 @@ -# RUN: yaml-bench -canonical %s +# RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace "Fun with \\ \" \a \b \e \f \ diff --git a/llvm/test/YAMLParser/spec-09-01.test b/llvm/test/YAMLParser/spec-09-01.test index 8999b4961626470..2b5a6f31166ddf1 100644 --- a/llvm/test/YAMLParser/spec-09-01.test +++ b/llvm/test/YAMLParser/spec-09-01.test @@ -1,4 +1,13 @@ -# RUN: yaml-bench -canonical %s +# RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace +# CHECK: !!map { +# CHECK-NEXT: ? !!str "simple key" +# CHECK-NEXT: : !!map { +# CHECK-NEXT: ? !!str "also simple" +# CHECK-NEXT: : !!str "value", +# CHECK-NEXT: ? !!str "not a\n simple key" +# CHECK-NEXT: : !!str "any\n value", +# CHECK-NEXT: }, +# CHECK-NEXT: } "simple key" : { "also simple" : value, diff --git a/llvm/test/YAMLParser/spec-09-02.test b/llvm/test/YAMLParser/spec-09-02.test index 3f8e49a8bd31079..6b68a00e3fc3e6f 100644 --- a/llvm/test/YAMLParser/spec-09-02.test +++ b/llvm/test/YAMLParser/spec-09-02.test @@ -1,14 +1,17 @@ -# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s +# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s --strict-whitespace +# CHECK: "as space\n trimmed \n specific\L\n escaped\t \n none" - "as space - trimmed +## Note: The example was originally taken from Spec 1.1, but the parsing rules +## have been changed since then. +## * The paragraph-separator character '\u2029' is excluded from line-break +## characters, so the original sequence "escaped\t\\\u2029" is no longer +## considered valid. This is replaced by "escaped\t\\\n" in the test source. +## See https://yaml.org/spec/1.2.2/ext/changes/ for details. - specific + "as space + trimmed + specific⨠escaped \ + none" - -# FIXME: The string below should actually be -# "as space trimmed\nspecific\nescaped\tnone", but the parser currently has -# a bug when parsing multiline quoted strings. -# CHECK: !!str "as space\n trimmed\n specific\n escaped\t none" diff --git a/llvm/test/YAMLParser/spec-09-03.test b/llvm/test/YAMLParser/spec-09-03.test index 3fb0d8b184abb16..c656058b7ff8b3e 100644 --- a/llvm/test/YAMLParser/spec-09-03.test +++ b/llvm/test/YAMLParser/spec-09-03.test @@ -1,4 +1,9 @@ -# RUN: yaml-bench -canonical %s +# RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace +# CHECK
[llvm-branch-commits] [llvm] 69bd4da - [YAMLParser] Fix handling escaped line breaks in double-quoted scalars
Author: Igor Kudrin Date: 2023-11-08T21:02:13-08:00 New Revision: 69bd4da46c438ce23ec0773f1d38abee800e6ed4 URL: https://github.com/llvm/llvm-project/commit/69bd4da46c438ce23ec0773f1d38abee800e6ed4 DIFF: https://github.com/llvm/llvm-project/commit/69bd4da46c438ce23ec0773f1d38abee800e6ed4.diff LOG: [YAMLParser] Fix handling escaped line breaks in double-quoted scalars Leading white spaces on the line following an escaped line break should be excluded from the content. See https://yaml.org/spec/1.2.2/#731-double-quoted-style. Added: Modified: llvm/lib/Support/YAMLParser.cpp llvm/test/YAMLParser/spec-09-02.test llvm/test/YAMLParser/spec-09-04.test llvm/test/YAMLParser/spec1.2-07-05.test Removed: diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 17d727b6cc07da8..b47cb3ae3b44a75 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -2107,14 +2107,13 @@ StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue return ""; } case '\r': +// Shrink the Windows-style EOL. +if (UnquotedValue.size() >= 2 && UnquotedValue[1] == '\n') + UnquotedValue = UnquotedValue.drop_front(1); +[[fallthrough]]; case '\n': -// Remove the new line. -if ( UnquotedValue.size() > 1 -&& (UnquotedValue[1] == '\r' || UnquotedValue[1] == '\n')) - UnquotedValue = UnquotedValue.substr(1); -// If this was just a single byte newline, it will get skipped -// below. -break; +UnquotedValue = UnquotedValue.drop_front(1).ltrim(" \t"); +continue; case '0': Storage.push_back(0x00); break; diff --git a/llvm/test/YAMLParser/spec-09-02.test b/llvm/test/YAMLParser/spec-09-02.test index 6b68a00e3fc3e6f..51ea61dd23273d3 100644 --- a/llvm/test/YAMLParser/spec-09-02.test +++ b/llvm/test/YAMLParser/spec-09-02.test @@ -1,5 +1,5 @@ # RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s --strict-whitespace -# CHECK: "as space\n trimmed \n specific\L\n escaped\t \n none" +# CHECK: "as space\n trimmed \n specific\L\n escaped\t\n none" ## Note: The example was originally taken from Spec 1.1, but the parsing rules ## have been changed since then. diff --git a/llvm/test/YAMLParser/spec-09-04.test b/llvm/test/YAMLParser/spec-09-04.test index 1e904eaa70992e5..e4f77ea83c7ac5f 100644 --- a/llvm/test/YAMLParser/spec-09-04.test +++ b/llvm/test/YAMLParser/spec-09-04.test @@ -1,5 +1,5 @@ # RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace -# CHECK: "first\n \tinner 1\t\n inner 2 last" +# CHECK: "first\n \tinner 1\t\n inner 2 last" "first inner 1 diff --git a/llvm/test/YAMLParser/spec1.2-07-05.test b/llvm/test/YAMLParser/spec1.2-07-05.test index 3ea0e5aa37743e4..f923f68d04295f9 100644 --- a/llvm/test/YAMLParser/spec1.2-07-05.test +++ b/llvm/test/YAMLParser/spec1.2-07-05.test @@ -1,5 +1,5 @@ # RUN: yaml-bench -canonical %s | FileCheck %s --strict-whitespace -# CHECK: "folded \nto a space,\t\n \nto a line feed, or \t \tnon-content" +# CHECK: "folded \nto a space,\t\n \nto a line feed, or \t \tnon-content" "folded to a space, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [YAMLParser] Unfold multi-line scalar values (PR #70898)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/70898 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [YAMLParser] Fix handling escaped line breaks in double-quoted scalars (PR #71775)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/71775 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [YAMLParser] Unfold multi-line scalar values (PR #70898)
@@ -2030,187 +2030,219 @@ bool Node::failed() const { } StringRef ScalarNode::getValue(SmallVectorImpl &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 &Storage, + StringRef LookupChars, + std::function &)> + UnescapeCallback) { + size_t I = UnquotedValue.find_first_of(LookupChars); + if (I == StringRef::npos) return UnquotedValue; - } else if (Value[0] == '\'') { // Single quoted. -// Pull off the leading and trailing 's. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -StringRef::size_type i = UnquotedValue.find('\''); -if (i != StringRef::npos) { - // We're going to need Storage. - Storage.clear(); - Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find('\'')) { -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -Storage.push_back('\''); -UnquotedValue = UnquotedValue.substr(i + 2); - } - llvm::append_range(Storage, UnquotedValue); - return StringRef(Storage.begin(), Storage.size()); -} -return UnquotedValue; - } - // Plain. - // Trim whitespace ('b-char' and 's-white'). - // NOTE: Alternatively we could change the scanner to not include whitespace - // here in the first place. - return Value.rtrim("\x0A\x0D\x20\x09"); -} -StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue - , StringRef::size_type i - , SmallVectorImpl &Storage) - const { - // Use Storage to build proper value. Storage.clear(); Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find_first_of("\\\r\n")) { -// Insert all previous chars into Storage. -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -// Chop off inserted chars. -UnquotedValue = UnquotedValue.substr(i); - -assert(!UnquotedValue.empty() && "Can't be empty!"); - -// Parse escape or line break. -switch (UnquotedValue[0]) { -case '\r': -case '\n': - Storage.push_back('\n'); - if ( UnquotedValue.size() > 1 - && (UnquotedValue[1] == '\r' || UnquotedValue[1] == '\n')) -UnquotedValue = UnquotedValue.substr(1); - UnquotedValue = UnquotedValue.substr(1); - break; -default: - if (UnquotedValue.size() == 1) { -Token T; -T.Range = StringRef(UnquotedValue.begin(), 1); -setError("Unrecognized escape code", T); -return ""; - } - UnquotedValue = UnquotedValue.substr(1); - switch (UnquotedValue[0]) { - default: { - Token T; - T.Range = StringRef(UnquotedValue.begin(), 1); - setError("Unrecognized escape code", T); - return ""; -} - case '\r': - case '\n': -// Remove the new line. -if ( UnquotedValue.size() > 1 -&& (UnquotedValue[1] == '\r' || UnquotedValue[1] == '\n')) - UnquotedValue = UnquotedValue.substr(1); -// If this was just a single byte newline, it will get skipped -// below. -break; - case '0': -Storage.push_back(0x00); -break; - case 'a': -Storage.push_back(0x07); -break; - case 'b': -Storage.push_back(0x08); -break; - case 't': - case 0x09: -Storage.push_back(0x09); -break; - case 'n': -Storage.push_back(0x0A); -break; - case 'v': -Storage.push_back(0x0B); -break; - case 'f': -Storage.push_back(0x0C); -break; - case 'r': -Storage.push_back(0x0D); -break; - case 'e': -Storage.push_back(0x1B); -break; + char LastNewLineAddedAs = '\0'; + for (; I != StringRef::npos; I = UnquotedValue.find_first_of(LookupChars)) { +if (UnquotedValue[I] != '\x0D' && UnquotedValue[I] != '\x0A') { + llvm::append_range(Storage, UnquotedValue.take_front(I)); + UnquotedValue = UnescapeCallback(UnquotedValue.drop_front(I), Storage); + LastNewLineAddedAs = '\0'; + contin
[llvm-branch-commits] [llvm] [YAMLParser] Unfold multi-line scalar values (PR #70898)
@@ -2030,187 +2030,219 @@ bool Node::failed() const { } StringRef ScalarNode::getValue(SmallVectorImpl &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 &Storage, + StringRef LookupChars, + std::function &)> + UnescapeCallback) { + size_t I = UnquotedValue.find_first_of(LookupChars); + if (I == StringRef::npos) return UnquotedValue; - } else if (Value[0] == '\'') { // Single quoted. -// Pull off the leading and trailing 's. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -StringRef::size_type i = UnquotedValue.find('\''); -if (i != StringRef::npos) { - // We're going to need Storage. - Storage.clear(); - Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find('\'')) { -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -Storage.push_back('\''); -UnquotedValue = UnquotedValue.substr(i + 2); - } - llvm::append_range(Storage, UnquotedValue); - return StringRef(Storage.begin(), Storage.size()); -} -return UnquotedValue; - } - // Plain. - // Trim whitespace ('b-char' and 's-white'). - // NOTE: Alternatively we could change the scanner to not include whitespace - // here in the first place. - return Value.rtrim("\x0A\x0D\x20\x09"); -} -StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue - , StringRef::size_type i - , SmallVectorImpl &Storage) - const { - // Use Storage to build proper value. Storage.clear(); Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find_first_of("\\\r\n")) { -// Insert all previous chars into Storage. -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -// Chop off inserted chars. -UnquotedValue = UnquotedValue.substr(i); - -assert(!UnquotedValue.empty() && "Can't be empty!"); - -// Parse escape or line break. -switch (UnquotedValue[0]) { -case '\r': -case '\n': - Storage.push_back('\n'); - if ( UnquotedValue.size() > 1 - && (UnquotedValue[1] == '\r' || UnquotedValue[1] == '\n')) -UnquotedValue = UnquotedValue.substr(1); - UnquotedValue = UnquotedValue.substr(1); - break; -default: - if (UnquotedValue.size() == 1) { -Token T; -T.Range = StringRef(UnquotedValue.begin(), 1); -setError("Unrecognized escape code", T); -return ""; - } - UnquotedValue = UnquotedValue.substr(1); - switch (UnquotedValue[0]) { - default: { - Token T; - T.Range = StringRef(UnquotedValue.begin(), 1); - setError("Unrecognized escape code", T); - return ""; -} - case '\r': - case '\n': -// Remove the new line. -if ( UnquotedValue.size() > 1 -&& (UnquotedValue[1] == '\r' || UnquotedValue[1] == '\n')) - UnquotedValue = UnquotedValue.substr(1); -// If this was just a single byte newline, it will get skipped -// below. -break; - case '0': -Storage.push_back(0x00); -break; - case 'a': -Storage.push_back(0x07); -break; - case 'b': -Storage.push_back(0x08); -break; - case 't': - case 0x09: -Storage.push_back(0x09); -break; - case 'n': -Storage.push_back(0x0A); -break; - case 'v': -Storage.push_back(0x0B); -break; - case 'f': -Storage.push_back(0x0C); -break; - case 'r': -Storage.push_back(0x0D); -break; - case 'e': -Storage.push_back(0x1B); -break; + char LastNewLineAddedAs = '\0'; + for (; I != StringRef::npos; I = UnquotedValue.find_first_of(LookupChars)) { +if (UnquotedValue[I] != '\x0D' && UnquotedValue[I] != '\x0A') { igorkudrin wrote: It was an idea to be a bit closer to the spec, where all special characters are defined by their value. I changed them back to mnemonics in the last updat
[llvm-branch-commits] [llvm] [YAMLParser] Unfold multi-line scalar values (PR #70898)
@@ -2030,187 +2030,219 @@ bool Node::failed() const { } StringRef ScalarNode::getValue(SmallVectorImpl &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 &Storage, + StringRef LookupChars, igorkudrin wrote: Added a description for the function and its arguments. https://github.com/llvm/llvm-project/pull/70898 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [YAMLParser] Unfold multi-line scalar values (PR #70898)
igorkudrin wrote: > I don't mean to make existing debt your problem, but if it isn't too much > work could you post a pre-patch that just adds the `FileCheck`s to the > existing tests where the behavior changes, so the test diff is more > self-documenting? * Added #71774 for the tests * Also added a unittest `YAMLParser.UnfoldsScalarValue` to check various combinations of line breaks and other characters. It seems like a `gtest`-based test suits better than a lit one. https://github.com/llvm/llvm-project/pull/70898 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits