r283416 - Use llvm::raw_string_ostream instead of std::stringstream (NFC)

Mehdi Amini via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 5 21:26:16 PDT 2016


Author: mehdi_amini
Date: Wed Oct  5 23:26:16 2016
New Revision: 283416

URL: http://llvm.org/viewvc/llvm-project?rev=283416&view=rev
Log:
Use llvm::raw_string_ostream instead of std::stringstream (NFC)

As a side effect, this avoid having to call .data() on the StringRef.

Modified:
    cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=283416&r1=283415&r2=283416&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed Oct  5 23:26:16 2016
@@ -39,7 +39,7 @@ CompilationDatabase::~CompilationDatabas
 std::unique_ptr<CompilationDatabase>
 CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
                                        std::string &ErrorMessage) {
-  std::stringstream ErrorStream;
+  llvm::raw_string_ostream ErrorStream(ErrorMessage);
   for (CompilationDatabasePluginRegistry::iterator
        It = CompilationDatabasePluginRegistry::begin(),
        Ie = CompilationDatabasePluginRegistry::end();
@@ -49,9 +49,8 @@ CompilationDatabase::loadFromDirectory(S
     if (std::unique_ptr<CompilationDatabase> DB =
             Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage))
       return DB;
-    ErrorStream << It->getName().data() << ": " << DatabaseErrorMessage << "\n";
+    ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n";
   }
-  ErrorMessage = ErrorStream.str();
   return nullptr;
 }
 




More information about the cfe-commits mailing list