diff --git a/clang/include/clang/Tooling/JSONCompilationDatabase.h b/clang/include/clang/Tooling/JSONCompilationDatabase.h index 59451563236b..894191f30386 100644 --- a/clang/include/clang/Tooling/JSONCompilationDatabase.h +++ b/clang/include/clang/Tooling/JSONCompilationDatabase.h @@ -81,8 +81,9 @@ public: private: /// \brief Constructs a JSON compilation database on a memory buffer. - JSONCompilationDatabase(llvm::MemoryBuffer *Database) - : Database(Database), YAMLStream(Database->getBuffer(), SM) {} + JSONCompilationDatabase(std::unique_ptr Database) + : Database(std::move(Database)), + YAMLStream(this->Database->getBuffer(), SM) {} /// \brief Parses the database file and creates the index. /// diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 088b42a0e4b2..3b5f7e28d02d 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -151,7 +151,7 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath, return nullptr; } std::unique_ptr Database( - new JSONCompilationDatabase(DatabaseBuffer->release())); + new JSONCompilationDatabase(std::move(*DatabaseBuffer))); if (!Database->parse(ErrorMessage)) return nullptr; return Database; @@ -163,7 +163,7 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, std::unique_ptr DatabaseBuffer( llvm::MemoryBuffer::getMemBuffer(DatabaseString)); std::unique_ptr Database( - new JSONCompilationDatabase(DatabaseBuffer.release())); + new JSONCompilationDatabase(std::move(DatabaseBuffer))); if (!Database->parse(ErrorMessage)) return nullptr; return Database;