<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 27, 2014 at 9:30 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Mon, Jan 27, 2014 at 9:16 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Mon, Jan 27, 2014 at 9:05 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Mon, Jan 27, 2014 at 8:51 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Mon, Jan 27, 2014 at 8:38 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Sat, Jan 25, 2014 at 3:07 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Sat, Jan 25, 2014 at 12:38 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Sat, Jan 25, 2014 at 12:04 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: compnerd<br>
Date: Sat Jan 25 14:04:44 2014<br>
New Revision: 200096<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=200096&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=200096&view=rev</a><br>
Log:<br>
unittests: explicit stringify StringRefs for conversion<br>
<br>
When clang is built outside of the LLVM tree (against a corresponding version),<br>
there is no definition providing for operator<<(std::ostream &, StringRef) which<br>
is required for the assertion routines in google-test tests.</blockquote><div><br></div></div><div>Hmm, why is this different for an in-tree vs an out-of-tree build?</div></div></div></div></blockquote><div><br></div></div>





<div>
Ugh, I should have phrased that better.  I meant a stand-alone vs combined clang build.</div></div></div></div></blockquote><div><br></div></div><div>The question, I think, still stands, doesn't it? Why is this different and can we make it not different instead of working around the difference?</div>




</div></div></div></blockquote><div><br></div></div><div>With this change, it no longer is different, we always convert the string ref to a string before printing.</div></div></div></div></blockquote><div><br></div></div>


<div>
Yes - but there's still some difference in the build system that lead to this problem and could lead to others. That's not good... we don't want to keep introducing/chasing down those problems. We should make the build systems similar and not necessitate this change.</div>


<div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>  The overload is provided by the unit-tests in LLVM (as that is the only place that the overload is actually used), and when clang is built standalone, the routine is not available.  </div>



</div></div></div></blockquote><div><br></div></div><div>I'm still not following. What do you mean by "the overload is provided by the unit-tests"? Is this declared in a unit test library and defined there - how does that declaration get found by the clang unit tests? </div>


</div></div></div></blockquote><div><br></div></div><div>Yeah, it is implemented in a unit test library that makes its way into the clang unit test link (I didn't track down the exact path that led to the library getting included into the clang build).  It is not the declaration that it is looking for, only the definition.</div>

</div></div></div></blockquote><div><br></div></div><div>Where is the function declared, then? (how do we end up calling a function that's not declared?)</div></div></div></div></blockquote><div><br></div><div>Its a template specialisation of std::ostream & operator<<(std::ostream &, T &); (from iostream) used to construct the assertion message (the StringRef is pushed into a std::ostringstream to construct an assertion message).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I suppose that we could provide the extra overload specifically for making the clang unit-tests compile standalone.</div>
<div><div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra"><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Avoid the<br>
compilation failure by explicitly stringifying the StringRef prior to use.<br>
<br>
Modified:<br>
    cfe/trunk/unittests/AST/DeclPrinterTest.cpp<br>
    cfe/trunk/unittests/AST/StmtPrinterTest.cpp<br>
    cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp<br>
<br>
Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff</a><br>








==============================================================================<br>
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)<br>
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Sat Jan 25 14:04:44 2014<br>
@@ -77,7 +77,8 @@ public:<br>
   OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));<br>
<br>
   if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName))<br>
-    return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";<br>
+    return testing::AssertionFailure()<br>
+      << "Parsing error in \"" << Code.str() << "\"";<br>
<br>
   if (Printer.getNumFoundDecls() == 0)<br>
     return testing::AssertionFailure()<br>
@@ -90,8 +91,8 @@ public:<br>
<br>
   if (Printer.getPrinted() != ExpectedPrinted)<br>
     return ::testing::AssertionFailure()<br>
-      << "Expected \"" << ExpectedPrinted << "\", "<br>
-         "got \"" << Printer.getPrinted() << "\"";<br>
+      << "Expected \"" << ExpectedPrinted.str() << "\", "<br>
+         "got \"" << Printer.getPrinted().str() << "\"";<br>
<br>
   return ::testing::AssertionSuccess();<br>
 }<br>
<br>
Modified: cfe/trunk/unittests/AST/StmtPrinterTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StmtPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StmtPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff</a><br>








==============================================================================<br>
--- cfe/trunk/unittests/AST/StmtPrinterTest.cpp (original)<br>
+++ cfe/trunk/unittests/AST/StmtPrinterTest.cpp Sat Jan 25 14:04:44 2014<br>
@@ -76,7 +76,8 @@ public:<br>
   OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));<br>
<br>
   if (!runToolOnCodeWithArgs(Factory->create(), Code, Args))<br>
-    return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";<br>
+    return testing::AssertionFailure()<br>
+      << "Parsing error in \"" << Code.str() << "\"";<br>
<br>
   if (Printer.getNumFoundStmts() == 0)<br>
     return testing::AssertionFailure()<br>
@@ -89,8 +90,8 @@ public:<br>
<br>
   if (Printer.getPrinted() != ExpectedPrinted)<br>
     return ::testing::AssertionFailure()<br>
-      << "Expected \"" << ExpectedPrinted << "\", "<br>
-         "got \"" << Printer.getPrinted() << "\"";<br>
+      << "Expected \"" << ExpectedPrinted.str() << "\", "<br>
+         "got \"" << Printer.getPrinted().str() << "\"";<br>
<br>
   return ::testing::AssertionSuccess();<br>
 }<br>
<br>
Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=200096&r1=200095&r2=200096&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=200096&r1=200095&r2=200096&view=diff</a><br>








==============================================================================<br>
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)<br>
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Sat Jan 25 14:04:44 2014<br>
@@ -24,7 +24,7 @@ static void expectFailure(StringRef JSON<br>
   std::string ErrorMessage;<br>
   EXPECT_EQ(NULL, JSONCompilationDatabase::loadFromBuffer(JSONDatabase,<br>
                                                           ErrorMessage))<br>
-    << "Expected an error because of: " << Explanation;<br>
+    << "Expected an error because of: " << Explanation.str();<br>
 }<br>
<br>
 TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</font></span></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><div><div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><div><div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div>