r215246 - Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.
David Blaikie
dblaikie at gmail.com
Fri Aug 8 15:01:06 PDT 2014
Author: dblaikie
Date: Fri Aug 8 17:01:06 2014
New Revision: 215246
URL: http://llvm.org/viewvc/llvm-project?rev=215246&view=rev
Log:
Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.
Modified:
cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
Modified: cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h?rev=215246&r1=215245&r2=215246&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h Fri Aug 8 17:01:06 2014
@@ -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<llvm::MemoryBuffer> Database)
+ : Database(std::move(Database)),
+ YAMLStream(this->Database->getBuffer(), SM) {}
/// \brief Parses the database file and creates the index.
///
Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=215246&r1=215245&r2=215246&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Fri Aug 8 17:01:06 2014
@@ -151,7 +151,7 @@ JSONCompilationDatabase::loadFromFile(St
return nullptr;
}
std::unique_ptr<JSONCompilationDatabase> Database(
- new JSONCompilationDatabase(DatabaseBuffer->release()));
+ new JSONCompilationDatabase(std::move(*DatabaseBuffer)));
if (!Database->parse(ErrorMessage))
return nullptr;
return Database;
@@ -163,7 +163,7 @@ JSONCompilationDatabase::loadFromBuffer(
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;
More information about the cfe-commits
mailing list