forked from OSchip/llvm-project
Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.
llvm-svn: 215246
This commit is contained in:
parent
2a3710ec9e
commit
b29bb4528a
|
@ -81,8 +81,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// \brief Constructs a JSON compilation database on a memory buffer.
|
/// \brief Constructs a JSON compilation database on a memory buffer.
|
||||||
JSONCompilationDatabase(llvm::MemoryBuffer *Database)
|
JSONCompilationDatabase(std::unique_ptr<llvm::MemoryBuffer> Database)
|
||||||
: Database(Database), YAMLStream(Database->getBuffer(), SM) {}
|
: Database(std::move(Database)),
|
||||||
|
YAMLStream(this->Database->getBuffer(), SM) {}
|
||||||
|
|
||||||
/// \brief Parses the database file and creates the index.
|
/// \brief Parses the database file and creates the index.
|
||||||
///
|
///
|
||||||
|
|
|
@ -151,7 +151,7 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::unique_ptr<JSONCompilationDatabase> Database(
|
std::unique_ptr<JSONCompilationDatabase> Database(
|
||||||
new JSONCompilationDatabase(DatabaseBuffer->release()));
|
new JSONCompilationDatabase(std::move(*DatabaseBuffer)));
|
||||||
if (!Database->parse(ErrorMessage))
|
if (!Database->parse(ErrorMessage))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return Database;
|
return Database;
|
||||||
|
@ -163,7 +163,7 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString,
|
||||||
std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer(
|
std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer(
|
||||||
llvm::MemoryBuffer::getMemBuffer(DatabaseString));
|
llvm::MemoryBuffer::getMemBuffer(DatabaseString));
|
||||||
std::unique_ptr<JSONCompilationDatabase> Database(
|
std::unique_ptr<JSONCompilationDatabase> Database(
|
||||||
new JSONCompilationDatabase(DatabaseBuffer.release()));
|
new JSONCompilationDatabase(std::move(DatabaseBuffer)));
|
||||||
if (!Database->parse(ErrorMessage))
|
if (!Database->parse(ErrorMessage))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return Database;
|
return Database;
|
||||||
|
|
Loading…
Reference in New Issue