[lld] r264921 - Change loadFileList to llvm::Error. NFC

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 13:44:14 PDT 2016


Author: pete
Date: Wed Mar 30 15:44:14 2016
New Revision: 264921

URL: http://llvm.org/viewvc/llvm-project?rev=264921&view=rev
Log:
Change loadFileList to llvm::Error.  NFC

Modified:
    lld/trunk/lib/Driver/DarwinLdDriver.cpp

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=264921&r1=264920&r2=264921&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Mar 30 15:44:14 2016
@@ -230,9 +230,9 @@ static std::error_code parseOrderFile(St
 // In this variant, the path is to a text file which contains a partial path
 // per line. The <dir> prefix is prepended to each partial path.
 //
-static std::error_code loadFileList(StringRef fileListPath,
-                                    MachOLinkingContext &ctx, bool forceLoad,
-                                    raw_ostream &diagnostics) {
+static llvm::Error loadFileList(StringRef fileListPath,
+                                MachOLinkingContext &ctx, bool forceLoad,
+                                raw_ostream &diagnostics) {
   // If there is a comma, split off <dir>.
   std::pair<StringRef, StringRef> opt = fileListPath.split(',');
   StringRef filePath = opt.first;
@@ -242,7 +242,7 @@ static std::error_code loadFileList(Stri
   ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
                                         MemoryBuffer::getFileOrSTDIN(filePath);
   if (std::error_code ec = mb.getError())
-    return ec;
+    return llvm::errorCodeToError(ec);
   StringRef buffer = mb->get()->getBuffer();
   while (!buffer.empty()) {
     // Split off each line in the file.
@@ -260,9 +260,9 @@ static std::error_code loadFileList(Stri
       path = ctx.copy(line);
     }
     if (!ctx.pathExists(path)) {
-      return make_dynamic_error_code(Twine("File not found '")
-                                     + path
-                                     + "'");
+      return llvm::make_error<GenericError>(Twine("File not found '")
+                                            + path
+                                            + "'");
     }
     if (ctx.testingFileUsage()) {
       diagnostics << "Found filelist entry " << canonicalizePath(path) << '\n';
@@ -270,7 +270,7 @@ static std::error_code loadFileList(Stri
     addFile(path, ctx, forceLoad, false, diagnostics);
     buffer = lineAndRest.second;
   }
-  return std::error_code();
+  return llvm::Error();
 }
 
 /// Parse number assuming it is base 16, but allow 0x prefix.
@@ -1095,12 +1095,14 @@ bool parse(llvm::ArrayRef<const char *>
       addFile(resolvedPath.get(), ctx, globalWholeArchive, upward, diagnostics);
       break;
     case OPT_filelist:
-      if (std::error_code ec = loadFileList(arg->getValue(),
-                                            ctx, globalWholeArchive,
-                                            diagnostics)) {
-        diagnostics << "error: " << ec.message()
-                    << ", processing '-filelist " << arg->getValue()
-                    << "'\n";
+      if (auto ec = loadFileList(arg->getValue(),
+                                 ctx, globalWholeArchive,
+                                 diagnostics)) {
+        handleAllErrors(std::move(ec), [&](const llvm::ErrorInfoBase &EI) {
+          diagnostics << "error: ";
+          EI.log(diagnostics);
+          diagnostics << ", processing '-filelist " << arg->getValue() << "'\n";
+        });
         return false;
       }
       break;




More information about the llvm-commits mailing list