From 2d487db031d954bfc93dcdab7dd77984e64363d0 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 6 Oct 2016 04:26:16 +0000 Subject: [PATCH] Use llvm::raw_string_ostream instead of std::stringstream (NFC) As a side effect, this avoid having to call .data() on the StringRef. llvm-svn: 283416 --- clang/lib/Tooling/CompilationDatabase.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp index 614870e..01f6261 100644 --- a/clang/lib/Tooling/CompilationDatabase.cpp +++ b/clang/lib/Tooling/CompilationDatabase.cpp @@ -39,7 +39,7 @@ CompilationDatabase::~CompilationDatabase() {} std::unique_ptr 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 DB = Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage)) return DB; - ErrorStream << It->getName().data() << ": " << DatabaseErrorMessage << "\n"; + ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n"; } - ErrorMessage = ErrorStream.str(); return nullptr; } -- 2.7.4