[lld] r286562 - Prevent at compile time converting from Error::success() to Expected<T>

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 20:29:26 PST 2016


Author: mehdi_amini
Date: Thu Nov 10 22:29:25 2016
New Revision: 286562

URL: http://llvm.org/viewvc/llvm-project?rev=286562&view=rev
Log:
Prevent at compile time converting from Error::success() to Expected<T>

This would trigger an assertion at runtime otherwise.

Differential Revision: https://reviews.llvm.org/D26482

Modified:
    lld/trunk/COFF/InputFiles.cpp
    lld/trunk/ELF/LTO.cpp
    lld/trunk/include/lld/Core/PassManager.h
    lld/trunk/lib/Core/Resolver.cpp
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/ReaderWriter/FileArchive.cpp
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
    lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
    lld/trunk/lib/ReaderWriter/MachO/ObjCPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp
    lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Thu Nov 10 22:29:25 2016
@@ -80,7 +80,7 @@ void ArchiveFile::parse() {
   // Seen is a map from member files to boolean values. Initially
   // all members are mapped to false, which indicates all these files
   // are not read yet.
-  Error Err;
+  Error Err = Error::success();
   for (auto &Child : File->children(Err))
     Seen[Child.getChildOffset()].clear();
   if (Err)

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Thu Nov 10 22:29:25 2016
@@ -59,7 +59,7 @@ static void diagnosticHandler(const Diag
 }
 
 static void checkError(Error E) {
-  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
+  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) -> Error {
     error(EIB.message());
     return Error::success();
   });

Modified: lld/trunk/include/lld/Core/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/PassManager.h?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/PassManager.h (original)
+++ lld/trunk/include/lld/Core/PassManager.h Thu Nov 10 22:29:25 2016
@@ -36,7 +36,7 @@ public:
     for (std::unique_ptr<Pass> &pass : _passes)
       if (llvm::Error EC = pass->perform(file))
         return EC;
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Nov 10 22:29:25 2016
@@ -100,7 +100,7 @@ llvm::Error Resolver::handleSharedLibrar
 
   if (auto ec = undefAddedOrError.takeError())
     return ec;
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 bool Resolver::doUndefinedAtom(OwningAtomPtr<UndefinedAtom> atom) {

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Nov 10 22:29:25 2016
@@ -289,7 +289,7 @@ static llvm::Error loadFileList(StringRe
     addFile(path, ctx, forceLoad, false, diagnostics);
     buffer = lineAndRest.second;
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 /// Parse number assuming it is base 16, but allow 0x prefix.

Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Thu Nov 10 22:29:25 2016
@@ -79,7 +79,7 @@ public:
   parseAllMembers(std::vector<std::unique_ptr<File>> &result) override {
     if (std::error_code ec = parse())
       return ec;
-    llvm::Error err;
+    llvm::Error err = llvm::Error::success();
     for (auto mf = _archive->child_begin(err), me = _archive->child_end();
          mf != me; ++mf) {
       std::unique_ptr<File> file;
@@ -122,7 +122,7 @@ public:
 protected:
   std::error_code doParse() override {
     // Make Archive object which will be owned by FileArchive object.
-    llvm::Error Err;
+    llvm::Error Err = llvm::Error::success();
     _archive.reset(new Archive(_mb->getMemBufferRef(), Err));
     if (Err)
       return errorToErrorCode(std::move(Err));

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Thu Nov 10 22:29:25 2016
@@ -540,7 +540,7 @@ llvm::Error ArchHandler_arm::getReferenc
     // Instruction contains branch to addend.
     displacement = getDisplacementFromThumbBranch(instruction, fixupAddress);
     *addend = fixupAddress + 4 + displacement;
-    return llvm::Error();
+      return llvm::Error::success();
   case ARM_THUMB_RELOC_BR22 | rPcRel | rLength4:
     // ex: bl _foo (and _foo is defined)
     if ((instruction & 0xD000F800) == 0x9000F000)
@@ -563,7 +563,7 @@ llvm::Error ArchHandler_arm::getReferenc
     // reloc.value is target atom's address.  Instruction contains branch
     // to atom+addend.
     *addend += (targetAddress - reloc.value);
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM_RELOC_BR24 | rPcRel | rExtern | rLength4:
     // ex: bl _foo (and _foo is undefined)
     if (((instruction & 0x0F000000) == 0x0A000000)
@@ -576,7 +576,7 @@ llvm::Error ArchHandler_arm::getReferenc
     // Instruction contains branch to addend.
     displacement = getDisplacementFromArmBranch(instruction);
     *addend = fixupAddress + 8 + displacement;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM_RELOC_BR24 | rPcRel | rLength4:
     // ex: bl _foo (and _foo is defined)
     if (((instruction & 0x0F000000) == 0x0A000000)
@@ -601,32 +601,32 @@ llvm::Error ArchHandler_arm::getReferenc
     // reloc.value is target atom's address.  Instruction contains branch
     // to atom+addend.
     *addend += (targetAddress - reloc.value);
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM_RELOC_VANILLA | rExtern | rLength4:
     // ex: .long _foo (and _foo is undefined)
     *kind = pointer32;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = instruction;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM_RELOC_VANILLA | rLength4:
     // ex: .long _foo (and _foo is defined)
     *kind = pointer32;
     if (auto ec = atomFromAddress(reloc.symbol, instruction, target, addend))
       return ec;
     *addend = clearThumbBit((uint32_t) * addend, *target);
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM_RELOC_VANILLA | rScattered | rLength4:
     // ex: .long _foo+a (and _foo is defined)
     *kind = pointer32;
     if (auto ec = atomFromAddress(0, reloc.value, target, addend))
       return ec;
     *addend += (clearThumbBit(instruction, *target) - reloc.value);
-    return llvm::Error();
+    return llvm::Error::success();
   default:
     return llvm::make_error<GenericError>("unsupported arm relocation type");
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error
@@ -847,7 +847,7 @@ ArchHandler_arm::getPairReferenceInfo(co
     value = clearThumbBit(value, *target);
     int64_t ta = (int64_t) value - (toAddress - fromAddress);
     *addend = ta - offsetInFrom;
-    return llvm::Error();
+    return llvm::Error::success();
   } else {
     uint32_t sectIndex;
     if (thumbReloc) {
@@ -895,7 +895,7 @@ ArchHandler_arm::getPairReferenceInfo(co
     }
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void ArchHandler_arm::applyFixupFinal(const Reference &ref, uint8_t *loc,

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Thu Nov 10 22:29:25 2016
@@ -389,56 +389,56 @@ llvm::Error ArchHandler_arm64::getRefere
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+      return llvm::Error::success();
   case ARM64_RELOC_PAGE21             | rPcRel | rExtern | rLength4:
     // ex: adrp x1, _foo at PAGE
     *kind = page21;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_PAGEOFF12                   | rExtern | rLength4:
     // ex: ldr x0, [x1, _foo at PAGEOFF]
     *kind = offset12KindFromInstruction(*(const little32_t *)fixupContent);
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_GOT_LOAD_PAGE21    | rPcRel | rExtern | rLength4:
     // ex: adrp x1, _foo at GOTPAGE
     *kind = gotPage21;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_GOT_LOAD_PAGEOFF12          | rExtern | rLength4:
     // ex: ldr x0, [x1, _foo at GOTPAGEOFF]
     *kind = gotOffset12;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_TLVP_LOAD_PAGE21   | rPcRel | rExtern | rLength4:
     // ex: adrp x1, _foo at TLVPAGE
     *kind = tlvPage21;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_TLVP_LOAD_PAGEOFF12         | rExtern | rLength4:
     // ex: ldr x0, [x1, _foo at TLVPAGEOFF]
     *kind = tlvOffset12;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_UNSIGNED                    | rExtern | rLength8:
     // ex: .quad _foo + N
     *kind = pointer64;
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = *(const little64_t *)fixupContent;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_UNSIGNED                              | rLength8:
      // ex: .quad Lfoo + N
      *kind = pointer64;
@@ -450,7 +450,7 @@ llvm::Error ArchHandler_arm64::getRefere
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   case ARM64_RELOC_POINTER_TO_GOT     | rPcRel | rExtern | rLength4:
     // ex: .long _foo at GOT - .
 
@@ -464,7 +464,7 @@ llvm::Error ArchHandler_arm64::getRefere
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = 0;
-    return llvm::Error();
+    return llvm::Error::success();
   default:
     return llvm::make_error<GenericError>("unsupported arm64 relocation type");
   }
@@ -485,7 +485,7 @@ llvm::Error ArchHandler_arm64::getPairRe
     if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
       return ec;
     *addend = reloc1.symbol;
-    return llvm::Error();
+    return llvm::Error::success();
   case ((ARM64_RELOC_ADDEND                                | rLength4) << 16 |
          ARM64_RELOC_PAGE21             | rPcRel | rExtern | rLength4):
     // ex: adrp x1, _foo at PAGE
@@ -493,7 +493,7 @@ llvm::Error ArchHandler_arm64::getPairRe
     if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
       return ec;
     *addend = reloc1.symbol;
-    return llvm::Error();
+    return llvm::Error::success();
   case ((ARM64_RELOC_ADDEND                                | rLength4) << 16 |
          ARM64_RELOC_PAGEOFF12                   | rExtern | rLength4): {
     // ex: ldr w0, [x1, _foo at PAGEOFF]
@@ -502,7 +502,7 @@ llvm::Error ArchHandler_arm64::getPairRe
     if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
       return ec;
     *addend = reloc1.symbol;
-    return llvm::Error();
+    return llvm::Error::success();
   }
   case ((ARM64_RELOC_SUBTRACTOR                  | rExtern | rLength8) << 16 |
          ARM64_RELOC_UNSIGNED                    | rExtern | rLength8):
@@ -522,7 +522,7 @@ llvm::Error ArchHandler_arm64::getPairRe
       return llvm::make_error<GenericError>(
                                     "paired relocs must have the same offset");
     *addend = (int64_t)*(const little64_t *)fixupContent + offsetInAtom;
-    return llvm::Error();
+    return llvm::Error::success();
   case ((ARM64_RELOC_SUBTRACTOR                  | rExtern | rLength4) << 16 |
          ARM64_RELOC_UNSIGNED                    | rExtern | rLength4):
     // ex: .quad _foo - .
@@ -530,7 +530,7 @@ llvm::Error ArchHandler_arm64::getPairRe
     if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
       return ec;
     *addend = (int32_t)*(const little32_t *)fixupContent + offsetInAtom;
-    return llvm::Error();
+    return llvm::Error::success();
   default:
     return llvm::make_error<GenericError>("unsupported arm64 relocation pair");
   }

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Thu Nov 10 22:29:25 2016
@@ -345,7 +345,7 @@ ArchHandler_x86::getReferenceInfo(const
   default:
     return llvm::make_error<GenericError>("unsupported i386 relocation type");
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error
@@ -403,7 +403,7 @@ ArchHandler_x86::getPairReferenceInfo(co
         *addend = fromAddress + value - toAddress;
       }
     }
-    return llvm::Error();
+    return llvm::Error::success();
     break;
   default:
     return llvm::make_error<GenericError>("unsupported i386 relocation type");

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Thu Nov 10 22:29:25 2016
@@ -382,22 +382,22 @@ ArchHandler_x86_64::getReferenceInfo(con
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = *(const little32_t *)fixupContent;
-    return llvm::Error();
+      return llvm::Error::success();
   case ripRel32Minus1:
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = (int32_t)*(const little32_t *)fixupContent + 1;
-    return llvm::Error();
+    return llvm::Error::success();
   case ripRel32Minus2:
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = (int32_t)*(const little32_t *)fixupContent + 2;
-    return llvm::Error();
+    return llvm::Error::success();
   case ripRel32Minus4:
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = (int32_t)*(const little32_t *)fixupContent + 4;
-    return llvm::Error();
+    return llvm::Error::success();
   case ripRel32Anon:
     targetAddress = fixupAddress + 4 + *(const little32_t *)fixupContent;
     return atomFromAddress(reloc.symbol, targetAddress, target, addend);
@@ -416,7 +416,7 @@ ArchHandler_x86_64::getReferenceInfo(con
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
       return ec;
     *addend = *(const little32_t *)fixupContent;
-    return llvm::Error();
+    return llvm::Error::success();
   case tlvInitSectionOffset:
   case pointer64:
     if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
@@ -429,7 +429,7 @@ ArchHandler_x86_64::getReferenceInfo(con
       assert(*addend == 0 && "TLV-init has non-zero addend?");
     } else
       *addend = *(const little64_t *)fixupContent;
-    return llvm::Error();
+    return llvm::Error::success();
   case pointer64Anon:
     targetAddress = *(const little64_t *)fixupContent;
     return atomFromAddress(reloc.symbol, targetAddress, target, addend);
@@ -474,7 +474,7 @@ ArchHandler_x86_64::getPairReferenceInfo
       *target = fromTarget;
     } else
       return llvm::make_error<GenericError>("Invalid pointer diff");
-    return llvm::Error();
+    return llvm::Error::success();
   }
   case ((X86_64_RELOC_SUBTRACTOR | rExtern | rLength4) << 16 |
         X86_64_RELOC_UNSIGNED    | rExtern | rLength4): {
@@ -490,7 +490,7 @@ ArchHandler_x86_64::getPairReferenceInfo
       *target = fromTarget;
     } else
       return llvm::make_error<GenericError>("Invalid pointer diff");
-    return llvm::Error();
+    return llvm::Error::success();
   }
   case ((X86_64_RELOC_SUBTRACTOR | rExtern | rLength8) << 16 |
         X86_64_RELOC_UNSIGNED              | rLength8):

Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Thu Nov 10 22:29:25 2016
@@ -298,7 +298,7 @@ private:
 
     // Skip rest of pass if no unwind info.
     if (unwindLocs.empty() && dwarfFrames.empty())
-      return llvm::Error();
+      return llvm::Error::success();
 
     // FIXME: if there are more than 4 personality functions then we need to
     // defer to DWARF info for the ones we don't put in the list. They should
@@ -353,7 +353,7 @@ private:
       return atom->contentType() == DefinedAtom::typeCompactUnwindInfo;
     });
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
   void collectCompactUnwindEntries(

Modified: lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp Thu Nov 10 22:29:25 2016
@@ -134,7 +134,7 @@ private:
     for (const GOTEntryAtom *slot : entries)
       mergedFile.addAtom(*slot);
 
-    return llvm::Error();
+      return llvm::Error::success();
   }
 
   bool shouldReplaceTargetWithGOTAtom(const Atom *target, bool canBypassGOT) {

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp Thu Nov 10 22:29:25 2016
@@ -474,7 +474,7 @@ llvm::Error LayoutPass::perform(SimpleFi
   });
 
   DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n");
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Thu Nov 10 22:29:25 2016
@@ -1030,7 +1030,7 @@ void MachOLinkingContext::finalizeInputF
 llvm::Error MachOLinkingContext::handleLoadedFile(File &file) {
   auto *machoFile = dyn_cast<MachOFile>(&file);
   if (!machoFile)
-    return llvm::Error();
+    return llvm::Error::success();
 
   // Check that the arch of the context matches that of the file.
   // Also set the arch of the context if it didn't have one.
@@ -1097,7 +1097,7 @@ llvm::Error MachOLinkingContext::handleL
     return llvm::make_error<GenericError>("different swift versions");
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 } // end namespace lld

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp Thu Nov 10 22:29:25 2016
@@ -70,12 +70,12 @@ static llvm::Error forEachLoadCommand(
       return llvm::make_error<GenericError>("Load command exceeds range");
 
     if (func(slc->cmd, slc->cmdsize, p))
-      return llvm::Error();
+      return llvm::Error::success();
 
     p += slc->cmdsize;
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 static std::error_code appendRelocations(Relocations &relocs, StringRef buffer,

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp Thu Nov 10 22:29:25 2016
@@ -657,7 +657,7 @@ llvm::Error MachOFileLayout::writeSingle
     ++sout;
   }
   lc = next;
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 template <typename T>
@@ -727,7 +727,7 @@ llvm::Error MachOFileLayout::writeSegmen
     }
     lc = reinterpret_cast<uint8_t*>(next);
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 static void writeVersionMinLoadCommand(const NormalizedFile &_file,
@@ -1007,7 +1007,7 @@ llvm::Error MachOFileLayout::writeLoadCo
       lc += sizeof(linkedit_data_command);
     }
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void MachOFileLayout::writeSectionContent() {
@@ -1537,7 +1537,7 @@ llvm::Error MachOFileLayout::writeBinary
   writeLinkEditContent();
   fob->commit();
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 /// Takes in-memory normalized view and writes a mach-o object file.

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Thu Nov 10 22:29:25 2016
@@ -985,7 +985,7 @@ llvm::Error Util::getSymbolTableRegion(c
   case Atom::scopeTranslationUnit:
     scope = 0;
     inGlobalsRegion = false;
-    return llvm::Error();
+      return llvm::Error::success();
   case Atom::scopeLinkageUnit:
     if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) &&
         _ctx.exportSymbolNamed(atom->name())) {
@@ -997,28 +997,28 @@ llvm::Error Util::getSymbolTableRegion(c
         // -keep_private_externs means keep in globals region as N_PEXT.
         scope = N_PEXT | N_EXT;
         inGlobalsRegion = true;
-        return llvm::Error();
+        return llvm::Error::success();
       }
     }
     // scopeLinkageUnit symbols are no longer global once linked.
     scope = N_PEXT;
     inGlobalsRegion = false;
-    return llvm::Error();
+    return llvm::Error::success();
   case Atom::scopeGlobal:
     if (_ctx.exportRestrictMode()) {
       if (_ctx.exportSymbolNamed(atom->name())) {
         scope = N_EXT;
         inGlobalsRegion = true;
-        return llvm::Error();
+        return llvm::Error::success();
       } else {
         scope = N_PEXT;
         inGlobalsRegion = false;
-        return llvm::Error();
+        return llvm::Error::success();
       }
     } else {
       scope = N_EXT;
       inGlobalsRegion = true;
-      return llvm::Error();
+      return llvm::Error::success();
     }
     break;
   }
@@ -1139,7 +1139,7 @@ llvm::Error Util::addSymbols(const lld::
     file.undefinedSymbols.push_back(sym);
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 const Atom *Util::targetOfLazyPointer(const DefinedAtom *lpAtom) {

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Thu Nov 10 22:29:25 2016
@@ -324,7 +324,7 @@ llvm::Error processSymboledSection(Defin
 
   // If section has no symbols and no content, there are no atoms.
   if (symbols.empty() && section.content.empty())
-    return llvm::Error();
+    return llvm::Error::success();
 
   if (symbols.empty()) {
     // Section has no symbols, put all content in one anoymous atom.
@@ -375,7 +375,7 @@ llvm::Error processSymboledSection(Defin
     });
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error processSection(DefinedAtom::ContentType atomType,
@@ -487,7 +487,7 @@ llvm::Error processSection(DefinedAtom::
       offset += size;
     }
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 const Section* findSectionCoveringAddress(const NormalizedFile &normalizedFile,
@@ -544,7 +544,7 @@ llvm::Error convertRelocs(const Section
     uint64_t offsetInSect = addr - sect->address;
     *atom = file.findAtomCoveringAddress(*sect, offsetInSect, &offsetInTarget);
     *addend = offsetInTarget;
-    return llvm::Error();
+    return llvm::Error::success();
   };
 
   // Utility function for ArchHandler to find atom by its symbol index.
@@ -580,14 +580,14 @@ llvm::Error convertRelocs(const Section
                                                             targetOffsetInSect);
       if (target) {
         *result = target;
-        return llvm::Error();
+        return llvm::Error::success();
       }
       return llvm::make_error<GenericError>("no atom found for defined symbol");
     } else if ((sym->type & N_TYPE) == N_UNDF) {
       const lld::Atom *target = file.findUndefAtom(sym->name);
       if (target) {
         *result = target;
-        return llvm::Error();
+        return llvm::Error::success();
       }
       return llvm::make_error<GenericError>("no undefined atom found for sym");
     } else {
@@ -684,7 +684,7 @@ llvm::Error convertRelocs(const Section
                          kind, offsetInAtom, target, addend);
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 bool isDebugInfoSection(const Section &section) {
@@ -1012,7 +1012,7 @@ static llvm::Error processAugmentationSt
 
   if (augStr[0] == '\0') {
     len = 1;
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
   if (augStr[0] != 'z')
@@ -1062,7 +1062,7 @@ static llvm::Error processAugmentationSt
   cieInfo._augmentationDataLength = offsetInAugmentationData;
 
   len = idx + 1;
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 static llvm::Error processCIE(const NormalizedFile &normalizedFile,
@@ -1167,7 +1167,7 @@ static llvm::Error processCIE(const Norm
 
   cieInfos[atom] = std::move(cieInfo);
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 static llvm::Error processFDE(const NormalizedFile &normalizedFile,
@@ -1311,7 +1311,7 @@ static llvm::Error processFDE(const Norm
     }
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error addEHFrameReferences(const NormalizedFile &normalizedFile,
@@ -1328,9 +1328,9 @@ llvm::Error addEHFrameReferences(const N
 
   // No __eh_frame so nothing to do.
   if (!ehFrameSection)
-    return llvm::Error();
+    return llvm::Error::success();
 
-  llvm::Error ehFrameErr;
+  llvm::Error ehFrameErr = llvm::Error::success();
   CIEInfoMap cieInfos;
 
   file.eachAtomInSection(*ehFrameSection,
@@ -1392,7 +1392,7 @@ llvm::Error parseObjCImageInfo(const Sec
 
   file.setSwiftVersion((flags >> 8) & 0xFF);
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 /// Converts normalized mach-o file into an lld::File and lld::Atoms.
@@ -1551,7 +1551,7 @@ normalizedObjectToAtoms(MachOFile *file,
   if (auto err = parseDebugInfo(*file, normalizedFile, copyRefs))
     return err;
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error
@@ -1582,7 +1582,7 @@ normalizedDylibToAtoms(MachODylibFile *f
     if (dep.kind == llvm::MachO::LC_REEXPORT_DYLIB)
       file->addReExportedDylib(dep.path);
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void relocatableSectionInfoForContentType(DefinedAtom::ContentType atomType,

Modified: lld/trunk/lib/ReaderWriter/MachO/ObjCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ObjCPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ObjCPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ObjCPass.cpp Thu Nov 10 22:29:25 2016
@@ -103,7 +103,7 @@ public:
     // Add the image info.
     mergedFile.addAtom(*getImageInfo());
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ShimPass.cpp Thu Nov 10 22:29:25 2016
@@ -66,7 +66,7 @@ public:
     }
     // Exit early if no shims needed.
     if (_targetToShim.empty())
-      return llvm::Error();
+      return llvm::Error::success();
 
     // Sort shim atoms so the layout order is stable.
     std::vector<const DefinedAtom *> shims;
@@ -83,7 +83,7 @@ public:
     for (const DefinedAtom *shim : shims)
       mergedFile.addAtom(*shim);
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Thu Nov 10 22:29:25 2016
@@ -218,7 +218,7 @@ public:
   llvm::Error perform(SimpleFile &mergedFile) override {
     // Skip this pass if output format uses text relocations instead of stubs.
     if (!this->noTextRelocs())
-      return llvm::Error();
+      return llvm::Error::success();
 
     // Scan all references in all atoms.
     for (const DefinedAtom *atom : mergedFile.defined()) {
@@ -245,7 +245,7 @@ public:
 
     // Exit early if no stubs needed.
     if (_targetToUses.empty())
-      return llvm::Error();
+      return llvm::Error::success();
 
     // First add help-common and GOT slots used by lazy binding.
     SimpleDefinedAtom *helperCommonAtom =
@@ -323,7 +323,7 @@ public:
       lazyOffset += target->name().size() + 12;
     }
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp Thu Nov 10 22:29:25 2016
@@ -107,7 +107,7 @@ private:
     for (const TLVPEntryAtom *slot : entries)
       mergedFile.addAtom(*slot);
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
   const DefinedAtom *makeTLVPEntry(const Atom *target) {

Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=286562&r1=286561&r2=286562&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Thu Nov 10 22:29:25 2016
@@ -1312,7 +1312,7 @@ public:
     const lld::File *fileRef = &file;
     yout << fileRef;
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:




More information about the llvm-commits mailing list