[PATCH] D61608: Fix YAML parser's Document::skip for null nodes

Thomas Finch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 13:18:47 PDT 2019


thomasfinch created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61608

Files:
  llvm/lib/Support/YAMLParser.cpp
  llvm/unittests/Support/YAMLParserTest.cpp


Index: llvm/unittests/Support/YAMLParserTest.cpp
===================================================================
--- llvm/unittests/Support/YAMLParserTest.cpp
+++ llvm/unittests/Support/YAMLParserTest.cpp
@@ -331,4 +331,15 @@
   EXPECT_TRUE(End == AnotherEnd);
 }
 
+TEST(YAMLParser, FlowSequenceTokensOutsideFlowSequence) {
+  auto FlowSequenceStrs = {",", "]", "}"};
+  SourceMgr SM;
+
+  for (auto &Str : FlowSequenceStrs) {
+    yaml::Stream Stream(Str, SM);
+    yaml::Document &Doc = *Stream.begin();
+    EXPECT_FALSE(Doc.skip());
+  }
+}
+
 } // end namespace llvm
Index: llvm/lib/Support/YAMLParser.cpp
===================================================================
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -2275,7 +2275,8 @@
   Token &T = peekNext();
   if (T.Kind == Token::TK_StreamEnd)
     return false;
-  if (T.Kind == Token::TK_DocumentEnd) {
+  if (T.Kind == Token::TK_DocumentEnd ||
+      (isa<NullNode>(Root) && T.Kind != Token::TK_DocumentStart)) {
     getNext();
     return skip();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61608.198328.patch
Type: text/x-patch
Size: 1055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190506/a8599179/attachment.bin>


More information about the llvm-commits mailing list