summaryrefslogtreecommitdiffstats
path: root/lld/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-07-06 17:43:22 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-07-06 17:43:22 +0000
commitc2199ecf1e833dc4b5e269141ecc72d3deb11616 (patch)
tree4178dc1b63afaed357bb4089a4b0c3240ce0012c /lld/lib
parent43f0aa6caf147789457bf64a7951bff4e3bef010 (diff)
downloadbcm5719-llvm-c2199ecf1e833dc4b5e269141ecc72d3deb11616.tar.gz
bcm5719-llvm-c2199ecf1e833dc4b5e269141ecc72d3deb11616.zip
Update for llvm api change.
llvm-svn: 212407
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/Core/InputGraph.cpp7
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp14
-rw-r--r--lld/lib/Passes/RoundTripNativePass.cpp7
-rw-r--r--lld/lib/Passes/RoundTripYAMLPass.cpp7
-rw-r--r--lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp7
5 files changed, 23 insertions, 19 deletions
diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp
index c269b0d40d2..5d8009ffb6e 100644
--- a/lld/lib/Core/InputGraph.cpp
+++ b/lld/lib/Core/InputGraph.cpp
@@ -86,10 +86,11 @@ void InputGraph::normalize() {
/// \brief Read the file into _buffer.
std::error_code FileNode::getBuffer(StringRef filePath) {
// Create a memory buffer
- std::unique_ptr<MemoryBuffer> mb;
- if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, mb))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+ MemoryBuffer::getFileOrSTDIN(filePath);
+ if (std::error_code ec = mb.getError())
return ec;
- _buffer = std::move(mb);
+ _buffer = std::move(mb.get());
return std::error_code();
}
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index 74d6a5bf835..f4b88869461 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -251,12 +251,12 @@ static bool parseSection(StringRef option, std::string &section,
static bool readFile(PECOFFLinkingContext &ctx, StringRef path,
ArrayRef<uint8_t> &result) {
- std::unique_ptr<MemoryBuffer> buf;
- if (MemoryBuffer::getFile(path, buf))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> buf = MemoryBuffer::getFile(path);
+ if (!buf)
return false;
+ StringRef Data = buf.get()->getBuffer();
result = ctx.allocate(ArrayRef<uint8_t>(
- reinterpret_cast<const uint8_t *>(buf->getBufferStart()),
- buf->getBufferSize()));
+ reinterpret_cast<const uint8_t *>(Data.begin()), Data.size()));
return true;
}
@@ -353,10 +353,10 @@ static bool parseExport(StringRef option,
// Read module-definition file.
static bool parseDef(StringRef option, llvm::BumpPtrAllocator &alloc,
std::vector<moduledef::Directive *> &result) {
- std::unique_ptr<MemoryBuffer> buf;
- if (MemoryBuffer::getFile(option, buf))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> buf = MemoryBuffer::getFile(option);
+ if (!buf)
return llvm::None;
- moduledef::Lexer lexer(std::move(buf));
+ moduledef::Lexer lexer(std::move(buf.get()));
moduledef::Parser parser(lexer, alloc);
return parser.parse(result);
}
diff --git a/lld/lib/Passes/RoundTripNativePass.cpp b/lld/lib/Passes/RoundTripNativePass.cpp
index fb5e9caa0d1..977fcab8462 100644
--- a/lld/lib/Passes/RoundTripNativePass.cpp
+++ b/lld/lib/Passes/RoundTripNativePass.cpp
@@ -37,11 +37,12 @@ void RoundTripNativePass::perform(std::unique_ptr<MutableFile> &mergedFile) {
// The file that is written would be kept around if there is a problem
// writing to the file or when reading atoms back from the file.
nativeWriter->writeFile(*mergedFile, tmpNativeFile.str());
- std::unique_ptr<MemoryBuffer> mb;
- if (MemoryBuffer::getFile(tmpNativeFile.str(), mb))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+ MemoryBuffer::getFile(tmpNativeFile.str());
+ if (!mb)
return;
- std::error_code ec = _context.registry().parseFile(mb, _nativeFile);
+ std::error_code ec = _context.registry().parseFile(mb.get(), _nativeFile);
if (ec) {
// Note: we need a way for Passes to report errors.
llvm_unreachable("native reader not registered or read error");
diff --git a/lld/lib/Passes/RoundTripYAMLPass.cpp b/lld/lib/Passes/RoundTripYAMLPass.cpp
index 9bb09e7d5b3..d96341fe8b0 100644
--- a/lld/lib/Passes/RoundTripYAMLPass.cpp
+++ b/lld/lib/Passes/RoundTripYAMLPass.cpp
@@ -37,11 +37,12 @@ void RoundTripYAMLPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
// The file that is written would be kept around if there is a problem
// writing to the file or when reading atoms back from the file.
yamlWriter->writeFile(*mergedFile, tmpYAMLFile.str());
- std::unique_ptr<MemoryBuffer> mb;
- if (MemoryBuffer::getFile(tmpYAMLFile.str(), mb))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+ MemoryBuffer::getFile(tmpYAMLFile.str());
+ if (!mb)
return;
- std::error_code ec = _context.registry().parseFile(mb, _yamlFile);
+ std::error_code ec = _context.registry().parseFile(mb.get(), _yamlFile);
if (ec) {
// Note: we need a way for Passes to report errors.
llvm_unreachable("yaml reader not registered or read error");
diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
index 0a4d2745e0d..59d429fd727 100644
--- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
@@ -958,11 +958,12 @@ public:
llvm::FileRemover coffFileRemover(*coffPath);
// Read and parse the COFF
- std::unique_ptr<MemoryBuffer> newmb;
- if (std::error_code ec = MemoryBuffer::getFile(*coffPath, newmb))
+ ErrorOr<std::unique_ptr<MemoryBuffer>> newmb =
+ MemoryBuffer::getFile(*coffPath);
+ if (std::error_code ec = newmb.getError())
return ec;
std::error_code ec;
- std::unique_ptr<FileCOFF> file(new FileCOFF(std::move(newmb), ec));
+ std::unique_ptr<FileCOFF> file(new FileCOFF(std::move(newmb.get()), ec));
if (ec)
return ec;
if (std::error_code ec = file->parse())
OpenPOWER on IntegriCloud