[lld] r212407 - Update for llvm api change.

Rafael Espindola rafael.espindola at gmail.com
Sun Jul 6 10:43:22 PDT 2014


Author: rafael
Date: Sun Jul  6 12:43:22 2014
New Revision: 212407

URL: http://llvm.org/viewvc/llvm-project?rev=212407&view=rev
Log:
Update for llvm api change.

Modified:
    lld/trunk/include/lld/Driver/CoreInputGraph.h
    lld/trunk/lib/Core/InputGraph.cpp
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Passes/RoundTripNativePass.cpp
    lld/trunk/lib/Passes/RoundTripYAMLPass.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
    lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
    lld/trunk/utils/linker-script-test/linker-script-test.cpp

Modified: lld/trunk/include/lld/Driver/CoreInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/CoreInputGraph.h?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/CoreInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/CoreInputGraph.h Sun Jul  6 12:43:22 2014
@@ -40,11 +40,12 @@ public:
       return make_error_code(llvm::errc::no_such_file_or_directory);
 
     // 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 ctx.registry().parseFile(_buffer, _files);
   }
 

Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Sun Jul  6 12:43:22 2014
@@ -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();
 }
 

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Sun Jul  6 12:43:22 2014
@@ -251,12 +251,12 @@ static bool parseSection(StringRef optio
 
 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);
 }

Modified: lld/trunk/lib/Passes/RoundTripNativePass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/RoundTripNativePass.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/lib/Passes/RoundTripNativePass.cpp (original)
+++ lld/trunk/lib/Passes/RoundTripNativePass.cpp Sun Jul  6 12:43:22 2014
@@ -37,11 +37,12 @@ void RoundTripNativePass::perform(std::u
   // 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");

Modified: lld/trunk/lib/Passes/RoundTripYAMLPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/RoundTripYAMLPass.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/lib/Passes/RoundTripYAMLPass.cpp (original)
+++ lld/trunk/lib/Passes/RoundTripYAMLPass.cpp Sun Jul  6 12:43:22 2014
@@ -37,11 +37,12 @@ void RoundTripYAMLPass::perform(std::uni
   // 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");

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Sun Jul  6 12:43:22 2014
@@ -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())

Modified: lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp (original)
+++ lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp Sun Jul  6 12:43:22 2014
@@ -30,8 +30,10 @@ using namespace lld::mach_o::normalized;
 // Normalized file to nf parameter.
 static void fromBinary(StringRef path, std::unique_ptr<MemoryBuffer> &mb,
                        std::unique_ptr<NormalizedFile> &nf, StringRef archStr) {
-  std::error_code ec = MemoryBuffer::getFile(path, mb);
+  ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr = MemoryBuffer::getFile(path);
+  std::error_code ec = mbOrErr.getError();
   EXPECT_FALSE(ec);
+  mb = std::move(mbOrErr.get());
 
   ErrorOr<std::unique_ptr<NormalizedFile>> r =
       lld::mach_o::normalized::readBinary(

Modified: lld/trunk/utils/linker-script-test/linker-script-test.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/utils/linker-script-test/linker-script-test.cpp?rev=212407&r1=212406&r2=212407&view=diff
==============================================================================
--- lld/trunk/utils/linker-script-test/linker-script-test.cpp (original)
+++ lld/trunk/utils/linker-script-test/linker-script-test.cpp Sun Jul  6 12:43:22 2014
@@ -26,12 +26,13 @@ int main(int argc, const char **argv) {
   llvm::PrettyStackTraceProgram X(argc, argv);
 
   {
-    std::unique_ptr<MemoryBuffer> mb;
-    if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(argv[1], mb)) {
+    ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+        MemoryBuffer::getFileOrSTDIN(argv[1]);
+    if (std::error_code ec = mb.getError()) {
       llvm::errs() << ec.message() << "\n";
       return 1;
     }
-    Lexer l(std::move(mb));
+    Lexer l(std::move(mb.get()));
     Token tok;
     while (true) {
       l.lex(tok);
@@ -41,12 +42,13 @@ int main(int argc, const char **argv) {
     }
   }
   {
-    std::unique_ptr<MemoryBuffer> mb;
-    if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(argv[1], mb)) {
+    ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
+        MemoryBuffer::getFileOrSTDIN(argv[1]);
+    if (std::error_code ec = mb.getError()) {
       llvm::errs() << ec.message() << "\n";
       return 1;
     }
-    Lexer l(std::move(mb));
+    Lexer l(std::move(mb.get()));
     Parser p(l);
     LinkerScript *ls = p.parse();
     if (ls)





More information about the llvm-commits mailing list