[PATCH] [YAML] Recover gracefully when deserializing invalid YAML input.

Alexander Kornienko alexfh at google.com
Wed Nov 13 08:55:42 PST 2013


  Does this handle empty input well (http://llvm.org/PR15927)? If so, please add a test.

  Plus a few comments inline.


================
Comment at: unittests/Support/YAMLIOTest.cpp:76
@@ +75,3 @@
+    EXPECT_EQ(doc.foo, 3);
+    EXPECT_EQ(doc.bar,5);
+  }
----------------
nit: add a space after the comma.

================
Comment at: unittests/Support/YAMLIOTest.cpp:1317-1318
@@ +1316,4 @@
+  {
+    Input yin("{foo:3, bar: 5}");
+    yin.setDiagHandler(suppressErrorMessages);
+    yin >> doc;
----------------
Andrew Tulloch wrote:
> This unfortunately outputs an error message into the unit test logs, since Document.begin() is called before we setDiagHandler. 
> 
> We can convert it to 
> 
> a) optionally pass DiagHandler in the constructor,
> b) lazily initialize the DocIterator,
> c) explicitly initialize Input, etc.  
> d) just ignore it.
> 
> Any thoughts on this?
Option a) seems like the best solution here.


http://llvm-reviews.chandlerc.com/D1236



More information about the llvm-commits mailing list