<div dir="ltr">That's really weird... I thought that the raw_ostream that this was outputting to was meant to go directly into the output file in the place of a YAML scalar (I wrote BinaryRef). Maybe something in YAMLIO changed? Where are the single quotes being added?<div>
<br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 31, 2014 at 1:31 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The escaping logic will ensure we get a pair of single quotes for zero-length data.<div>Previously, we would represent an empty string as a pair of single quotes around a pair of double quotes for an empty string.<div>
<br>
</div><div>If you disagree, please construct a test-case in which the behavior post r204312 is wrong.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>David Majnemer</div></font></span></div>
<div class="HOEnZb"><div class="h5"><br><div>On Mon Mar 31 2014 at 10:26:51 AM, Sean Silva <<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">???<div><br></div><div>This doesn't make any sense. The emission of the empty quotes is there on purpose (hence the test case!) and actually was put there to fix a bug where BinaryRef::writeAsHex would emit an empty string, which is not a valid YAML scalar. If you want to just get a raw hex string, I would recommend segregating the previous functionality into a method writeAsHexScalar and add a new writeAsHexRaw with the behavior that you are wanting here.</div>


<div><br></div><div>Rui, were you the one that ran into the issue with the empty string and added this test case?</div></div><div dir="ltr">
<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 20, 2014 at 2:28 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Thu Mar 20 01:28:52 2014<br>
New Revision: 204312<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=204312&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=204312&view=rev</a><br>
Log:<br>
Object: Don't double-escape empty hexdata<br>
<br>
We would emit a pair of double quotes inside a pair of single quotes.<br>
Just use a pair of single quotes.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Object/YAML.cpp<br>
    llvm/trunk/unittests/Object/YAMLTest.cpp<br>
<br>
Modified: llvm/trunk/lib/Object/YAML.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/YAML.cpp?rev=204312&r1=204311&r2=204312&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/YAML.cpp?rev=204312&r1=204311&r2=204312&view=diff</a><br>



==============================================================================<br>
--- llvm/trunk/lib/Object/YAML.cpp (original)<br>
+++ llvm/trunk/lib/Object/YAML.cpp Thu Mar 20 01:28:52 2014<br>
@@ -51,10 +51,8 @@ void BinaryRef::writeAsBinary(raw_ostrea<br>
 }<br>
<br>
 void BinaryRef::writeAsHex(raw_ostream &OS) const {<br>
-  if (binary_size() == 0) {<br>
-    OS << "\"\"";<br>
+  if (binary_size() == 0)<br>
     return;<br>
-  }<br>
   if (DataIsHexString) {<br>
     OS.write((const char *)Data.data(), Data.size());<br>
     return;<br>
<br>
Modified: llvm/trunk/unittests/Object/YAMLTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Object/YAMLTest.cpp?rev=204312&r1=204311&r2=204312&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Object/YAMLTest.cpp?rev=204312&r1=204311&r2=204312&view=diff</a><br>



==============================================================================<br>
--- llvm/trunk/unittests/Object/YAMLTest.cpp (original)<br>
+++ llvm/trunk/unittests/Object/YAMLTest.cpp Thu Mar 20 01:28:52 2014<br>
@@ -34,5 +34,5 @@ TEST(ObjectYAML, BinaryRef) {<br>
   llvm::raw_svector_ostream OS(Buf);<br>
   yaml::Output YOut(OS);<br>
   YOut << BH;<br>
-  EXPECT_NE(OS.str().find("\"\""), StringRef::npos);<br>
+  EXPECT_NE(OS.str().find("''"), StringRef::npos);<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote>
</div></div></blockquote></div><br></div>