On Mon, Jan 27, 2014 at 8:38 AM, David Blaikie <[email protected]> wrote:
> > > > On Sat, Jan 25, 2014 at 3:07 PM, Saleem Abdulrasool <[email protected] > > wrote: > >> On Sat, Jan 25, 2014 at 12:38 PM, Richard Smith <[email protected]>wrote: >> >>> On Sat, Jan 25, 2014 at 12:04 PM, Saleem Abdulrasool < >>> [email protected]> wrote: >>> >>>> Author: compnerd >>>> Date: Sat Jan 25 14:04:44 2014 >>>> New Revision: 200096 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=200096&view=rev >>>> Log: >>>> unittests: explicit stringify StringRefs for conversion >>>> >>>> When clang is built outside of the LLVM tree (against a corresponding >>>> version), >>>> there is no definition providing for operator<<(std::ostream &, >>>> StringRef) which >>>> is required for the assertion routines in google-test tests. >>> >>> >>> Hmm, why is this different for an in-tree vs an out-of-tree build? >>> >> >> Ugh, I should have phrased that better. I meant a stand-alone vs >> combined clang build. >> > > 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? > With this change, it no longer is different, we always convert the string ref to a string before printing. 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. I suppose that we could provide the extra overload specifically for making the clang unit-tests compile standalone. > >> >>> Avoid the >>>> compilation failure by explicitly stringifying the StringRef prior to >>>> use. >>>> >>>> Modified: >>>> cfe/trunk/unittests/AST/DeclPrinterTest.cpp >>>> cfe/trunk/unittests/AST/StmtPrinterTest.cpp >>>> cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp >>>> >>>> Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp >>>> URL: >>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff >>>> >>>> ============================================================================== >>>> --- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original) >>>> +++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Sat Jan 25 14:04:44 2014 >>>> @@ -77,7 +77,8 @@ public: >>>> OwningPtr<FrontendActionFactory> >>>> Factory(newFrontendActionFactory(&Finder)); >>>> >>>> if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) >>>> - return testing::AssertionFailure() << "Parsing error in \"" << >>>> Code << "\""; >>>> + return testing::AssertionFailure() >>>> + << "Parsing error in \"" << Code.str() << "\""; >>>> >>>> if (Printer.getNumFoundDecls() == 0) >>>> return testing::AssertionFailure() >>>> @@ -90,8 +91,8 @@ public: >>>> >>>> if (Printer.getPrinted() != ExpectedPrinted) >>>> return ::testing::AssertionFailure() >>>> - << "Expected \"" << ExpectedPrinted << "\", " >>>> - "got \"" << Printer.getPrinted() << "\""; >>>> + << "Expected \"" << ExpectedPrinted.str() << "\", " >>>> + "got \"" << Printer.getPrinted().str() << "\""; >>>> >>>> return ::testing::AssertionSuccess(); >>>> } >>>> >>>> Modified: cfe/trunk/unittests/AST/StmtPrinterTest.cpp >>>> URL: >>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StmtPrinterTest.cpp?rev=200096&r1=200095&r2=200096&view=diff >>>> >>>> ============================================================================== >>>> --- cfe/trunk/unittests/AST/StmtPrinterTest.cpp (original) >>>> +++ cfe/trunk/unittests/AST/StmtPrinterTest.cpp Sat Jan 25 14:04:44 2014 >>>> @@ -76,7 +76,8 @@ public: >>>> OwningPtr<FrontendActionFactory> >>>> Factory(newFrontendActionFactory(&Finder)); >>>> >>>> if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) >>>> - return testing::AssertionFailure() << "Parsing error in \"" << >>>> Code << "\""; >>>> + return testing::AssertionFailure() >>>> + << "Parsing error in \"" << Code.str() << "\""; >>>> >>>> if (Printer.getNumFoundStmts() == 0) >>>> return testing::AssertionFailure() >>>> @@ -89,8 +90,8 @@ public: >>>> >>>> if (Printer.getPrinted() != ExpectedPrinted) >>>> return ::testing::AssertionFailure() >>>> - << "Expected \"" << ExpectedPrinted << "\", " >>>> - "got \"" << Printer.getPrinted() << "\""; >>>> + << "Expected \"" << ExpectedPrinted.str() << "\", " >>>> + "got \"" << Printer.getPrinted().str() << "\""; >>>> >>>> return ::testing::AssertionSuccess(); >>>> } >>>> >>>> Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp >>>> URL: >>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=200096&r1=200095&r2=200096&view=diff >>>> >>>> ============================================================================== >>>> --- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original) >>>> +++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Sat Jan 25 >>>> 14:04:44 2014 >>>> @@ -24,7 +24,7 @@ static void expectFailure(StringRef JSON >>>> std::string ErrorMessage; >>>> EXPECT_EQ(NULL, JSONCompilationDatabase::loadFromBuffer(JSONDatabase, >>>> >>>> ErrorMessage)) >>>> - << "Expected an error because of: " << Explanation; >>>> + << "Expected an error because of: " << Explanation.str(); >>>> } >>>> >>>> TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) { >>>> >>>> >>>> _______________________________________________ >>>> cfe-commits mailing list >>>> [email protected] >>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >>>> >>> >>> >> >> >> -- >> Saleem Abdulrasool >> compnerd (at) compnerd (dot) org >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >> >> > -- Saleem Abdulrasool compnerd (at) compnerd (dot) org
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
