diff options
Diffstat (limited to 'lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r-- | lib/Tooling/JSONCompilationDatabase.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index 8b8bd293851f..3b5f7e28d02d 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -118,15 +118,15 @@ std::vector<std::string> unescapeCommandLine( } class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { - CompilationDatabase *loadFromDirectory(StringRef Directory, - std::string &ErrorMessage) override { + std::unique_ptr<CompilationDatabase> + loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override { SmallString<1024> JSONDatabasePath(Directory); llvm::sys::path::append(JSONDatabasePath, "compile_commands.json"); std::unique_ptr<CompilationDatabase> Database( JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage)); if (!Database) return nullptr; - return Database.release(); + return Database; } }; @@ -141,7 +141,7 @@ X("json-compilation-database", "Reads JSON formatted compilation databases"); // and thus register the JSONCompilationDatabasePlugin. volatile int JSONAnchorSource = 0; -JSONCompilationDatabase * +std::unique_ptr<JSONCompilationDatabase> JSONCompilationDatabase::loadFromFile(StringRef FilePath, std::string &ErrorMessage) { llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> DatabaseBuffer = @@ -151,22 +151,22 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath, return nullptr; } std::unique_ptr<JSONCompilationDatabase> Database( - new JSONCompilationDatabase(DatabaseBuffer->release())); + new JSONCompilationDatabase(std::move(*DatabaseBuffer))); if (!Database->parse(ErrorMessage)) return nullptr; - return Database.release(); + return Database; } -JSONCompilationDatabase * +std::unique_ptr<JSONCompilationDatabase> JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage) { std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer( llvm::MemoryBuffer::getMemBuffer(DatabaseString)); std::unique_ptr<JSONCompilationDatabase> Database( - new JSONCompilationDatabase(DatabaseBuffer.release())); + new JSONCompilationDatabase(std::move(DatabaseBuffer))); if (!Database->parse(ErrorMessage)) return nullptr; - return Database.release(); + return Database; } std::vector<CompileCommand> |