]> granicus.if.org Git - clang/commitdiff
Use llvm::raw_string_ostream instead of std::stringstream (NFC)
authorMehdi Amini <mehdi.amini@apple.com>
Thu, 6 Oct 2016 04:26:16 +0000 (04:26 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Thu, 6 Oct 2016 04:26:16 +0000 (04:26 +0000)
As a side effect, this avoid having to call .data() on the StringRef.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283416 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/CompilationDatabase.cpp

index 614870e2f28527bbfbe914920b7293b6c3e2c26d..01f62616fb0d5cd4227c4b7705dbc3d11bc940b7 100644 (file)
@@ -39,7 +39,7 @@ CompilationDatabase::~CompilationDatabase() {}
 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(StringRef BuildDirectory,
     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;
 }