summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-08 22:01:06 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-08 22:01:06 +0000
commitb29bb4528a4c6a1da8cb776357adb2c4f1e21cab (patch)
treeafd0a0cbb3d6e40affc186f4c0cf756271ac4be3 /clang
parent2a3710ec9e36c42219267321b1a4bc05eb00dcdd (diff)
downloadbcm5719-llvm-b29bb4528a4c6a1da8cb776357adb2c4f1e21cab.tar.gz
bcm5719-llvm-b29bb4528a4c6a1da8cb776357adb2c4f1e21cab.zip
Sure-up MemoryBuffer ownership in JSONCompilationDatabase's ctor.
llvm-svn: 215246
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Tooling/JSONCompilationDatabase.h5
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp4
2 files changed, 5 insertions, 4 deletions
diff --git a/clang/include/clang/Tooling/JSONCompilationDatabase.h b/clang/include/clang/Tooling/JSONCompilationDatabase.h
index 59451563236..894191f3038 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<llvm::MemoryBuffer> 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 088b42a0e4b..3b5f7e28d02 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<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(StringRef DatabaseString,
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;
OpenPOWER on IntegriCloud