Update for llvm api change.

llvm-svn: 212408
This commit is contained in:
Rafael Espindola
2014-07-06 17:43:24 +00:00
parent c2199ecf1e
commit 2d2b420ab9
14 changed files with 79 additions and 53 deletions

View File

@@ -144,15 +144,14 @@ volatile int JSONAnchorSource = 0;
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromFile(StringRef FilePath,
std::string &ErrorMessage) {
std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer;
std::error_code Result =
llvm::MemoryBuffer::getFile(FilePath, DatabaseBuffer);
if (Result) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> DatabaseBuffer =
llvm::MemoryBuffer::getFile(FilePath);
if (std::error_code Result = DatabaseBuffer.getError()) {
ErrorMessage = "Error while opening JSON database: " + Result.message();
return nullptr;
}
std::unique_ptr<JSONCompilationDatabase> Database(
new JSONCompilationDatabase(DatabaseBuffer.release()));
new JSONCompilationDatabase(DatabaseBuffer->release()));
if (!Database->parse(ErrorMessage))
return nullptr;
return Database.release();