Prevent at compile time converting from Error::success() to Expected<T>
authorMehdi Amini <mehdi.amini@apple.com>
Fri, 11 Nov 2016 04:29:25 +0000 (04:29 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Fri, 11 Nov 2016 04:29:25 +0000 (04:29 +0000)
This would trigger an assertion at runtime otherwise.

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

llvm-svn: 286562

67 files changed:
lld/COFF/InputFiles.cpp
lld/ELF/LTO.cpp
lld/include/lld/Core/PassManager.h
lld/lib/Core/Resolver.cpp
lld/lib/Driver/DarwinLdDriver.cpp
lld/lib/ReaderWriter/FileArchive.cpp
lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
lld/lib/ReaderWriter/MachO/GOTPass.cpp
lld/lib/ReaderWriter/MachO/LayoutPass.cpp
lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
lld/lib/ReaderWriter/MachO/ObjCPass.cpp
lld/lib/ReaderWriter/MachO/ShimPass.cpp
lld/lib/ReaderWriter/MachO/StubsPass.cpp
lld/lib/ReaderWriter/MachO/TLVPass.cpp
lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lldb/include/lldb/Target/Process.h
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Host/common/NativeBreakpoint.cpp
lldb/source/Host/common/NativeBreakpointList.cpp
lldb/source/Host/common/NativeProcessProtocol.cpp
lldb/source/Host/common/NativeWatchpointList.cpp
lldb/source/Host/common/SoftwareBreakpoint.cpp
lldb/source/Host/posix/FileSystem.cpp
lldb/source/Host/posix/MainLoopPosix.cpp
lldb/source/Host/posix/PipePosix.cpp
lldb/source/Interpreter/OptionGroupVariable.cpp
lldb/source/Interpreter/OptionValueString.cpp
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/source/Plugins/Platform/Android/AdbClient.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Thread.cpp
lldb/source/Utility/ModuleCache.cpp
lldb/tools/lldb-server/lldb-platform.cpp
lldb/unittests/Utility/ModuleCacheTest.cpp
llvm/include/llvm/Support/Error.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/unittests/Support/ErrorTest.cpp

index 52dec2e..ead0d39 100644 (file)
@@ -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)
index 34fef9f..76446b3 100644 (file)
@@ -59,7 +59,7 @@ static void diagnosticHandler(const DiagnosticInfo &DI) {
 }
 
 static void checkError(Error E) {
-  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
+  handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) -> Error {
     error(EIB.message());
     return Error::success();
   });
index 71a25cc..09b417a 100644 (file)
@@ -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:
index ef694fd..e7cfaaa 100644 (file)
@@ -100,7 +100,7 @@ llvm::Error Resolver::handleSharedLibrary(File &file) {
 
   if (auto ec = undefAddedOrError.takeError())
     return ec;
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 bool Resolver::doUndefinedAtom(OwningAtomPtr<UndefinedAtom> atom) {
index cb2bef5..9b4aede 100644 (file)
@@ -289,7 +289,7 @@ static llvm::Error loadFileList(StringRef fileListPath,
     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.
index 087b73e..799f947 100644 (file)
@@ -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));
index 3286fe0..1351599 100644 (file)
@@ -540,7 +540,7 @@ llvm::Error ArchHandler_arm::getReferenceInfo(
     // 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::getReferenceInfo(
     // 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::getReferenceInfo(
     // 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::getReferenceInfo(
     // 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(const normalized::Relocation &reloc1,
     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(const normalized::Relocation &reloc1,
     }
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void ArchHandler_arm::applyFixupFinal(const Reference &ref, uint8_t *loc,
index fb748e2..25cd9e1 100644 (file)
@@ -389,56 +389,56 @@ llvm::Error ArchHandler_arm64::getReferenceInfo(
     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@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@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@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@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@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@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::getReferenceInfo(
     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@GOT - .
 
@@ -464,7 +464,7 @@ llvm::Error ArchHandler_arm64::getReferenceInfo(
     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::getPairReferenceInfo(
     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@PAGE
@@ -493,7 +493,7 @@ llvm::Error ArchHandler_arm64::getPairReferenceInfo(
     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@PAGEOFF]
@@ -502,7 +502,7 @@ llvm::Error ArchHandler_arm64::getPairReferenceInfo(
     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::getPairReferenceInfo(
       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::getPairReferenceInfo(
     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");
   }
index 15f1f79..c940ea5 100644 (file)
@@ -345,7 +345,7 @@ ArchHandler_x86::getReferenceInfo(const Relocation &reloc,
   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(const normalized::Relocation &reloc1,
         *addend = fromAddress + value - toAddress;
       }
     }
-    return llvm::Error();
+    return llvm::Error::success();
     break;
   default:
     return llvm::make_error<GenericError>("unsupported i386 relocation type");
index 391cbf6..832c660 100644 (file)
@@ -382,22 +382,22 @@ ArchHandler_x86_64::getReferenceInfo(const Relocation &reloc,
     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(const Relocation &reloc,
     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(const Relocation &reloc,
       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(const normalized::Relocation &reloc1,
       *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(const normalized::Relocation &reloc1,
       *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):
index 6f5ab83..49d5184 100644 (file)
@@ -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(
index 6cdca0a..9dfb54d 100644 (file)
@@ -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) {
index dd2ee85..24dbf79 100644 (file)
@@ -474,7 +474,7 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
   });
 
   DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n");
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void addLayoutPass(PassManager &pm, const MachOLinkingContext &ctx) {
index dc9e6dd..d6ab0b4 100644 (file)
@@ -1030,7 +1030,7 @@ void MachOLinkingContext::finalizeInputFiles() {
 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::handleLoadedFile(File &file) {
     return llvm::make_error<GenericError>("different swift versions");
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 } // end namespace lld
index d701135..23c7ea1 100644 (file)
@@ -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,
index 25d719c..e853faf 100644 (file)
@@ -657,7 +657,7 @@ llvm::Error MachOFileLayout::writeSingleSegmentLoadCommand(uint8_t *&lc) {
     ++sout;
   }
   lc = next;
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 template <typename T>
@@ -727,7 +727,7 @@ llvm::Error MachOFileLayout::writeSegmentLoadCommands(uint8_t *&lc) {
     }
     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::writeLoadCommands() {
       lc += sizeof(linkedit_data_command);
     }
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void MachOFileLayout::writeSectionContent() {
@@ -1537,7 +1537,7 @@ llvm::Error MachOFileLayout::writeBinary(StringRef path) {
   writeLinkEditContent();
   fob->commit();
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 /// Takes in-memory normalized view and writes a mach-o object file.
index 86fda67..5f81d2b 100644 (file)
@@ -985,7 +985,7 @@ llvm::Error Util::getSymbolTableRegion(const DefinedAtom* atom,
   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(const DefinedAtom* atom,
         // -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 &atomFile,
     file.undefinedSymbols.push_back(sym);
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 const Atom *Util::targetOfLazyPointer(const DefinedAtom *lpAtom) {
index 6c8c09b..cfa2ae1 100644 (file)
@@ -324,7 +324,7 @@ llvm::Error processSymboledSection(DefinedAtom::ContentType atomType,
 
   // 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(DefinedAtom::ContentType atomType,
     });
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error processSection(DefinedAtom::ContentType atomType,
@@ -487,7 +487,7 @@ llvm::Error processSection(DefinedAtom::ContentType atomType,
       offset += size;
     }
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 const Section* findSectionCoveringAddress(const NormalizedFile &normalizedFile,
@@ -544,7 +544,7 @@ llvm::Error convertRelocs(const Section &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 &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 &section,
                          kind, offsetInAtom, target, addend);
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 bool isDebugInfoSection(const Section &section) {
@@ -1012,7 +1012,7 @@ static llvm::Error processAugmentationString(const uint8_t *augStr,
 
   if (augStr[0] == '\0') {
     len = 1;
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
   if (augStr[0] != 'z')
@@ -1062,7 +1062,7 @@ static llvm::Error processAugmentationString(const uint8_t *augStr,
   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 NormalizedFile &normalizedFile,
 
   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 NormalizedFile &normalizedFile,
     }
   }
 
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 llvm::Error addEHFrameReferences(const NormalizedFile &normalizedFile,
@@ -1328,9 +1328,9 @@ llvm::Error addEHFrameReferences(const NormalizedFile &normalizedFile,
 
   // 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 Section &sect,
 
   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 *file,
     if (dep.kind == llvm::MachO::LC_REEXPORT_DYLIB)
       file->addReExportedDylib(dep.path);
   }
-  return llvm::Error();
+  return llvm::Error::success();
 }
 
 void relocatableSectionInfoForContentType(DefinedAtom::ContentType atomType,
index ba24b3f..4712d8c 100644 (file)
@@ -103,7 +103,7 @@ public:
     // Add the image info.
     mergedFile.addAtom(*getImageInfo());
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:
index cd53671..ff559d7 100644 (file)
@@ -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:
index d53b78b..19e2bc5 100644 (file)
@@ -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:
index 7a8496c..e362e50 100644 (file)
@@ -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) {
index d35aa6f..59ca430 100644 (file)
@@ -1312,7 +1312,7 @@ public:
     const lld::File *fileRef = &file;
     yout << fileRef;
 
-    return llvm::Error();
+    return llvm::Error::success();
   }
 
 private:
index a3a2871..f2add84 100644 (file)
@@ -1082,9 +1082,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) {
-    return Error::success();
-  }
+  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { return Error(); }
 
   //------------------------------------------------------------------
   /// Called before attaching to a process.
@@ -1097,7 +1095,7 @@ public:
   //------------------------------------------------------------------
   virtual Error WillAttachToProcessWithName(const char *process_name,
                                             bool wait_for_launch) {
-    return Error::success();
+    return Error();
   }
 
   //------------------------------------------------------------------
@@ -1206,7 +1204,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error WillLaunch(Module *module) { return Error::success(); }
+  virtual Error WillLaunch(Module *module) { return Error(); }
 
   //------------------------------------------------------------------
   /// Launch a new process.
@@ -1252,7 +1250,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error WillResume() { return Error::success(); }
+  virtual Error WillResume() { return Error(); }
 
   //------------------------------------------------------------------
   /// Resumes all of a process's threads as configured using the
@@ -1296,7 +1294,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error WillHalt() { return Error::success(); }
+  virtual Error WillHalt() { return Error(); }
 
   //------------------------------------------------------------------
   /// Halts a running process.
@@ -1343,7 +1341,7 @@ public:
   /// @return
   ///     Returns an error object.
   //------------------------------------------------------------------
-  virtual Error WillDetach() { return Error::success(); }
+  virtual Error WillDetach() { return Error(); }
 
   //------------------------------------------------------------------
   /// Detaches from a running or stopped process.
@@ -1381,7 +1379,7 @@ public:
   ///     Process::DoSignal(int), otherwise an error describing what
   ///     prevents the signal from being sent.
   //------------------------------------------------------------------
-  virtual Error WillSignal() { return Error::success(); }
+  virtual Error WillSignal() { return Error(); }
 
   //------------------------------------------------------------------
   /// Sends a process a UNIX signal \a signal.
@@ -1397,7 +1395,7 @@ public:
     return error;
   }
 
-  virtual Error WillDestroy() { return Error::success(); }
+  virtual Error WillDestroy() { return Error(); }
 
   virtual Error DoDestroy() = 0;
 
index 6273744..0795033 100644 (file)
@@ -231,7 +231,7 @@ Error CommandObjectDisassemble::CommandOptions::OptionParsingFinished(
     ExecutionContext *execution_context) {
   if (!some_location_specified)
     current_function = true;
-  return Error::success();
+  return Error();
 }
 
 llvm::ArrayRef<OptionDefinition>
index d98a3ee..ba477cd 100644 (file)
@@ -303,7 +303,7 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) {
     return Error("as it does not refer to a pointer");
   if (pointee.IsVoidType())
     return Error("as it refers to a pointer to void");
-  return Error::success();
+  return Error();
 }
 
 bool CommandObjectExpression::EvaluateExpression(const char *expr,
index 7ad1f09..b980e15 100644 (file)
@@ -788,7 +788,7 @@ Error ModuleList::GetSharedModule(const ModuleSpec &module_spec,
               *did_create_ptr = true;
 
             shared_module_list.ReplaceEquivalent(module_sp);
-            return Error::success();
+            return Error();
           }
         }
       } else {
index a2cc048..d61a2f5 100644 (file)
@@ -53,7 +53,7 @@ Error NativeBreakpoint::Enable() {
       log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
                   " already enabled, ignoring.",
                   __FUNCTION__, m_addr);
-    return Error::success();
+    return Error();
   }
 
   // Log and enable.
@@ -85,7 +85,7 @@ Error NativeBreakpoint::Disable() {
       log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
                   " already disabled, ignoring.",
                   __FUNCTION__, m_addr);
-    return Error::success();
+    return Error();
   }
 
   // Log and disable.
index 58e1c3e..df5bce8 100644 (file)
@@ -40,7 +40,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint,
                   __FUNCTION__, addr);
 
     iter->second->AddRef();
-    return Error::success();
+    return Error();
   }
 
   // Create a new breakpoint using the given create func.
@@ -205,7 +205,7 @@ Error NativeBreakpointList::GetBreakpoint(lldb::addr_t addr,
 
   // Disable it.
   breakpoint_sp = iter->second;
-  return Error::success();
+  return Error();
 }
 
 Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf,
@@ -225,5 +225,5 @@ Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf,
     auto opcode_size = software_bp_sp->m_opcode_size;
     ::memcpy(opcode_addr, saved_opcodes, opcode_size);
   }
-  return Error::success();
+  return Error();
 }
index a22d7f8..d77b8b2 100644 (file)
@@ -405,7 +405,7 @@ Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
 
   arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture();
   if (arch.IsValid())
-    return Error::success();
+    return Error();
   else
     return Error("failed to retrieve a valid architecture from the exe module");
 }
index be9d2eb..5948adf 100644 (file)
@@ -17,12 +17,12 @@ using namespace lldb_private;
 Error NativeWatchpointList::Add(addr_t addr, size_t size, uint32_t watch_flags,
                                 bool hardware) {
   m_watchpoints[addr] = {addr, size, watch_flags, hardware};
-  return Error::success();
+  return Error();
 }
 
 Error NativeWatchpointList::Remove(addr_t addr) {
   m_watchpoints.erase(addr);
-  return Error::success();
+  return Error();
 }
 
 const NativeWatchpointList::WatchpointMap &
index 6cb8126..3d57b7d 100644 (file)
@@ -103,7 +103,7 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint(
   // breakpoint.
   breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes,
                                              bp_opcode_bytes, bp_opcode_size));
-  return Error::success();
+  return Error();
 }
 
 Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
@@ -219,7 +219,7 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
     log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS",
                 __FUNCTION__, addr);
 
-  return Error::success();
+  return Error();
 }
 
 // -------------------------------------------------------------------
index 0567f60..aaa53ce 100644 (file)
@@ -62,7 +62,7 @@ Error FileSystem::MakeDirectory(const FileSpec &file_spec,
       } break;
       case EEXIST: {
         if (file_spec.IsDirectory())
-          return Error::success(); // It is a directory and it already exists
+          return Error(); // It is a directory and it already exists
       } break;
       }
     }
@@ -210,7 +210,7 @@ Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
 
   dst = FileSpec(real_path, false);
 
-  return Error::success();
+  return Error();
 }
 
 #if defined(__NetBSD__)
index 59a7612..08c969e 100644 (file)
@@ -160,7 +160,7 @@ Error MainLoopPosix::Run() {
       it->second.callback(*this); // Do the work
 
       if (m_terminate_request)
-        return Error::success();
+        return Error();
     }
 
     for (int fd : read_fds) {
@@ -175,8 +175,8 @@ Error MainLoopPosix::Run() {
       it->second(*this); // Do the work
 
       if (m_terminate_request)
-        return Error::success();
+        return Error();
     }
   }
-  return Error::success();
+  return Error();
 }
index 142f6c9..4e0810c 100644 (file)
@@ -206,7 +206,7 @@ Error PipePosix::OpenAsWriterWithTimeout(
     }
   }
 
-  return Error::success();
+  return Error();
 }
 
 int PipePosix::GetReadFileDescriptor() const { return m_fds[READ]; }
index a3150d1..c257506 100644 (file)
@@ -59,13 +59,13 @@ static Error ValidateNamedSummary(const char *str, void *) {
   if (DataVisualization::NamedSummaryFormats::GetSummaryFormat(
           ConstString(str), summary_sp) == false)
     return Error("must specify a valid named summary");
-  return Error::success();
+  return Error();
 }
 
 static Error ValidateSummaryString(const char *str, void *) {
   if (!str || !str[0])
     return Error("must specify a non-empty summary string");
-  return Error::success();
+  return Error();
 }
 
 OptionGroupVariable::OptionGroupVariable(bool show_frame_options)
index b5ce38c..e61ead0 100644 (file)
@@ -133,7 +133,7 @@ Error OptionValueString::SetCurrentValue(llvm::StringRef value) {
       return error;
   }
   m_current_value.assign(value);
-  return Error::success();
+  return Error();
 }
 
 Error OptionValueString::AppendToCurrentValue(const char *value) {
@@ -148,5 +148,5 @@ Error OptionValueString::AppendToCurrentValue(const char *value) {
     } else
       m_current_value.append(value);
   }
-  return Error::success();
+  return Error();
 }
index 73c3cca..fcbba93 100644 (file)
@@ -213,7 +213,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() {
 }
 
 // AD: Needs to be updated?
-Error DynamicLoaderHexagonDYLD::CanLoadImage() { return Error::success(); }
+Error DynamicLoaderHexagonDYLD::CanLoadImage() { return Error(); }
 
 void DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module,
                                                     addr_t link_map_addr,
index 9af4646..8678f61 100644 (file)
@@ -221,7 +221,7 @@ void DynamicLoaderPOSIXDYLD::DidLaunch() {
   }
 }
 
-Error DynamicLoaderPOSIXDYLD::CanLoadImage() { return Error::success(); }
+Error DynamicLoaderPOSIXDYLD::CanLoadImage() { return Error(); }
 
 void DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module,
                                                   addr_t link_map_addr,
index 09ed903..20bf360 100644 (file)
@@ -61,7 +61,7 @@ void DynamicLoaderWindowsDYLD::DidAttach() {}
 
 void DynamicLoaderWindowsDYLD::DidLaunch() {}
 
-Error DynamicLoaderWindowsDYLD::CanLoadImage() { return Error::success(); }
+Error DynamicLoaderWindowsDYLD::CanLoadImage() { return Error(); }
 
 ConstString DynamicLoaderWindowsDYLD::GetPluginName() {
   return GetPluginNameStatic();
index 592bc84..79ad8f5 100644 (file)
@@ -381,7 +381,7 @@ Error AdbClient::internalShell(const char *command, uint32_t timeout_ms,
                    std::string(output_buf.begin(), output_buf.end()).c_str());
   }
 
-  return Error::success();
+  return Error();
 }
 
 Error AdbClient::Shell(const char *command, uint32_t timeout_ms,
@@ -412,7 +412,7 @@ Error AdbClient::ShellToFile(const char *command, uint32_t timeout_ms,
   dst.close();
   if (!dst)
     return Error("Failed to write file %s", output_filename.c_str());
-  return Error::success();
+  return Error();
 }
 
 std::unique_ptr<AdbClient::SyncService>
@@ -536,7 +536,7 @@ Error AdbClient::SyncService::internalStat(const FileSpec &remote_file,
   mode = extractor.GetU32(&offset);
   size = extractor.GetU32(&offset);
   mtime = extractor.GetU32(&offset);
-  return Error::success();
+  return Error();
 }
 
 Error AdbClient::SyncService::PullFile(const FileSpec &remote_file,
@@ -641,7 +641,7 @@ Error AdbClient::SyncService::PullFileChunk(std::vector<char> &buffer,
   } else
     return Error("Pull failed with unknown response: %s", response_id.c_str());
 
-  return Error::success();
+  return Error();
 }
 
 Error AdbClient::SyncService::ReadAllBytes(void *buffer, size_t size) {
index 43720c0..a870929 100644 (file)
@@ -252,7 +252,7 @@ Error PlatformFreeBSD::GetFileWithUUID(const FileSpec &platform_file,
 
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 //------------------------------------------------------------------
index 017a1bf..69f5c29 100644 (file)
@@ -179,7 +179,7 @@ Error PlatformKalimba::ResolveExecutable(
 Error PlatformKalimba::GetFileWithUUID(const FileSpec & /*platform_file*/,
                                        const UUID * /*uuid_ptr*/,
                                        FileSpec & /*local_file*/) {
-  return Error::success();
+  return Error();
 }
 
 //------------------------------------------------------------------
index b8fae14..5b6bc35 100644 (file)
@@ -341,7 +341,7 @@ Error PlatformLinux::GetFileWithUUID(const FileSpec &platform_file,
 
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 //------------------------------------------------------------------
index 0b5d394..e6da63e 100644 (file)
@@ -71,7 +71,7 @@ lldb_private::Error PlatformAppleSimulator::LaunchProcess(
 
   if (spawned) {
     launch_info.SetProcessID(spawned.GetPID());
-    return Error::success();
+    return Error();
   } else
     return spawned.GetError();
 #else
@@ -164,7 +164,7 @@ Error PlatformAppleSimulator::ConnectRemote(Args &args) {
 Error PlatformAppleSimulator::DisconnectRemote() {
 #if defined(__APPLE__)
   m_device.reset();
-  return Error::success();
+  return Error();
 #else
   Error err;
   err.SetErrorString(UNSUPPORTED_ERROR);
index 8cecd38..a92a8da 100644 (file)
@@ -393,7 +393,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache(
                                 module_spec.GetArchitecture());
           module_sp.reset(new Module(local_spec));
           module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
-          return Error::success();
+          return Error();
         }
       }
 
@@ -433,7 +433,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache(
                       (IsHost() ? "host" : "remote"),
                       module_spec.GetFileSpec().GetDirectory().AsCString(),
                       module_spec.GetFileSpec().GetFilename().AsCString());
-        return Error::success();
+        return Error();
       }
 
       // bring in the remote module file
@@ -455,7 +455,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache(
         ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
         module_sp.reset(new Module(local_spec));
         module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
-        return Error::success();
+        return Error();
       } else
         return Error("unable to obtain valid module file");
     } else
index c506302..89b61bf 100644 (file)
@@ -247,7 +247,7 @@ Error PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file,
 
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 lldb_private::Error
@@ -264,7 +264,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
     if (local_os_build.compare(remote_os_build) == 0) {
       // same OS version: the local file is good enough
       local_file = platform_file;
-      return Error::success();
+      return Error();
     } else {
       // try to find the file in the cache
       std::string cache_path(GetLocalCacheDirectory());
@@ -273,7 +273,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
       FileSpec module_cache_spec(cache_path, false);
       if (module_cache_spec.Exists()) {
         local_file = module_cache_spec;
-        return Error::success();
+        return Error();
       }
       // bring in the remote module file
       FileSpec module_cache_folder =
@@ -288,13 +288,13 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
         return err;
       if (module_cache_spec.Exists()) {
         local_file = module_cache_spec;
-        return Error::success();
+        return Error();
       } else
         return Error("unable to obtain valid module file");
     }
   }
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx,
index b7fa7aa..cb3c124 100644 (file)
@@ -244,7 +244,7 @@ Error PlatformNetBSD::GetFileWithUUID(const FileSpec &platform_file,
 
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 //------------------------------------------------------------------
index 100500f..b751de7 100644 (file)
@@ -207,7 +207,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
 
   if (IsHost()) {
     if (FileSpec::Equal(source, destination, true))
-      return Error::success();
+      return Error();
     // cp src dst
     // chown uid:gid dst
     std::string src_path(source.GetPath());
@@ -223,10 +223,10 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
     if (status != 0)
       return Error("unable to perform copy");
     if (uid == UINT32_MAX && gid == UINT32_MAX)
-      return Error::success();
+      return Error();
     if (chown_file(this, dst_path.c_str(), uid, gid) != 0)
       return Error("unable to perform chown");
-    return Error::success();
+    return Error();
   } else if (m_remote_platform_sp) {
     if (GetSupportsRSync()) {
       std::string src_path(source.GetPath());
@@ -254,7 +254,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
         // Don't chown a local file for a remote system
         //                if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
         //                    return Error("unable to perform chown");
-        return Error::success();
+        return Error();
       }
       // if we are still here rsync has failed - let's try the slow way before
       // giving up
@@ -323,7 +323,7 @@ lldb_private::Error PlatformPOSIX::GetFile(
     RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL, 10);
     if (status != 0)
       return Error("unable to perform copy");
-    return Error::success();
+    return Error();
   } else if (m_remote_platform_sp) {
     if (GetSupportsRSync()) {
       StreamString command;
@@ -343,7 +343,7 @@ lldb_private::Error PlatformPOSIX::GetFile(
       int retcode;
       Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60);
       if (retcode == 0)
-        return Error::success();
+        return Error();
       // If we are here, rsync has failed - let's try the slow way before giving
       // up
     }
@@ -745,7 +745,7 @@ Error PlatformPOSIX::EvaluateLibdlExpression(
 
   if (result_valobj_sp->GetError().Fail())
     return result_valobj_sp->GetError();
-  return Error::success();
+  return Error();
 }
 
 uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
@@ -833,7 +833,7 @@ Error PlatformPOSIX::UnloadImage(lldb_private::Process *process,
       return Error("expression failed: \"%s\"", expr.GetData());
     process->ResetImageToken(image_token);
   }
-  return Error::success();
+  return Error();
 }
 
 lldb::ProcessSP PlatformPOSIX::ConnectProcess(const char *connect_url,
index 534c773..d25bb7b 100644 (file)
@@ -527,7 +527,7 @@ Error PlatformWindows::GetFileWithUUID(const FileSpec &platform_file,
 
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 Error PlatformWindows::GetSharedModule(
index 007ce1a..8b9972f 100644 (file)
@@ -196,7 +196,7 @@ Error PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file,
                                                FileSpec &local_file) {
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 //------------------------------------------------------------------
@@ -482,7 +482,7 @@ Error PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) {
 Error PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) {
   if (!KillSpawnedProcess(pid))
     return Error("failed to kill remote spawned process");
-  return Error::success();
+  return Error();
 }
 
 lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
index 2decd29..77b9fc8 100644 (file)
@@ -414,7 +414,7 @@ lldb_private::DynamicLoader *ProcessKDP::GetDynamicLoader() {
   return m_dyld_ap.get();
 }
 
-Error ProcessKDP::WillResume() { return Error::success(); }
+Error ProcessKDP::WillResume() { return Error(); }
 
 Error ProcessKDP::DoResume() {
   Error error;
index d9fa3f8..840a792 100644 (file)
@@ -258,7 +258,7 @@ bool ProcessElfCore::UpdateThreadList(ThreadList &old_thread_list,
 
 void ProcessElfCore::RefreshStateAfterStop() {}
 
-Error ProcessElfCore::DoDestroy() { return Error::success(); }
+Error ProcessElfCore::DoDestroy() { return Error(); }
 
 //------------------------------------------------------------------
 // Process Queries
@@ -304,7 +304,7 @@ Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr,
       region_info.SetExecutable(MemoryRegionInfo::eNo);
       region_info.SetMapped(MemoryRegionInfo::eNo);
     }
-    return Error::success();
+    return Error();
   }
 
   region_info.GetRange().SetRangeBase(load_addr);
@@ -313,7 +313,7 @@ Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr,
   region_info.SetWritable(MemoryRegionInfo::eNo);
   region_info.SetExecutable(MemoryRegionInfo::eNo);
   region_info.SetMapped(MemoryRegionInfo::eNo);
-  return Error::success();
+  return Error();
 }
 
 size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
index f0494a8..49733a5 100644 (file)
@@ -2672,7 +2672,7 @@ lldb_private::Error GDBRemoteCommunicationClient::RunShellCommand(
     response.GetEscapedBinaryData(output);
     if (command_output)
       command_output->assign(output);
-    return Error::success();
+    return Error();
   }
   return Error("unable to send packet");
 }
index 440651f..0897611 100644 (file)
@@ -197,13 +197,13 @@ Error GDBRemoteCommunicationServerLLGS::SetLaunchArguments(
                  __FUNCTION__);
 
   m_process_launch_info.SetArguments(const_cast<const char **>(args), true);
-  return Error::success();
+  return Error();
 }
 
 Error GDBRemoteCommunicationServerLLGS::SetLaunchFlags(
     unsigned int launch_flags) {
   m_process_launch_info.GetFlags().Set(launch_flags);
-  return Error::success();
+  return Error();
 }
 
 Error GDBRemoteCommunicationServerLLGS::LaunchProcess() {
@@ -988,7 +988,7 @@ Error GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) {
     return error;
   }
 
-  return Error::success();
+  return Error();
 }
 
 void GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding() {
index 07d3080..c0fbccb 100644 (file)
@@ -1252,7 +1252,7 @@ Error ProcessGDBRemote::WillResume() {
   m_continue_S_tids.clear();
   m_jstopinfo_sp.reset();
   m_jthreadsinfo_sp.reset();
-  return Error::success();
+  return Error();
 }
 
 Error ProcessGDBRemote::DoResume() {
@@ -3246,7 +3246,7 @@ Error ProcessGDBRemote::EstablishConnectionIfNeeded(
     const ProcessInfo &process_info) {
   // Make sure we aren't already connected?
   if (m_gdb_comm.IsConnected())
-    return Error::success();
+    return Error();
 
   PlatformSP platform_sp(GetTarget().GetPlatform());
   if (platform_sp && !platform_sp->IsHost())
@@ -4408,7 +4408,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) {
 
     XMLNode root_element = doc.GetRootElement("library-list-svr4");
     if (!root_element)
-      return Error::success();
+      return Error();
 
     // main link map structure
     llvm::StringRef main_lm = root_element.GetAttributeValue("main-lm");
@@ -4494,7 +4494,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) {
 
     XMLNode root_element = doc.GetRootElement("library-list");
     if (!root_element)
-      return Error::success();
+      return Error();
 
     root_element.ForEachChildElementWithName(
         "library", [log, &list](const XMLNode &library) -> bool {
@@ -4538,7 +4538,7 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) {
     return Error(0, ErrorType::eErrorTypeGeneric);
   }
 
-  return Error::success();
+  return Error();
 }
 
 lldb::ModuleSP ProcessGDBRemote::LoadModuleAtAddress(const FileSpec &file,
@@ -4662,7 +4662,7 @@ Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file,
       // The file is not loaded into the inferior
       is_loaded = false;
       load_addr = LLDB_INVALID_ADDRESS;
-      return Error::success();
+      return Error();
     }
 
     return Error(
@@ -4672,7 +4672,7 @@ Error ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file,
   if (response.IsNormalResponse()) {
     is_loaded = true;
     load_addr = response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS);
-    return Error::success();
+    return Error();
   }
 
   return Error("Unknown error happened during sending the load address packet");
index 1b32117..f83499c 100644 (file)
@@ -461,7 +461,7 @@ void ProcessMachCore::RefreshStateAfterStop() {
   // SetThreadStopInfo (m_last_stop_packet);
 }
 
-Error ProcessMachCore::DoDestroy() { return Error::success(); }
+Error ProcessMachCore::DoDestroy() { return Error(); }
 
 //------------------------------------------------------------------
 // Process Queries
@@ -564,7 +564,7 @@ Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr,
       region_info.SetExecutable(MemoryRegionInfo::eNo);
       region_info.SetMapped(MemoryRegionInfo::eNo);
     }
-    return Error::success();
+    return Error();
   }
 
   region_info.GetRange().SetRangeBase(load_addr);
@@ -573,7 +573,7 @@ Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr,
   region_info.SetWritable(MemoryRegionInfo::eNo);
   region_info.SetExecutable(MemoryRegionInfo::eNo);
   region_info.SetMapped(MemoryRegionInfo::eNo);
-  return Error::success();
+  return Error();
 }
 
 void ProcessMachCore::Clear() { m_thread_list.Clear(); }
index 5b390d8..46d8df8 100644 (file)
@@ -133,7 +133,7 @@ ConstString ProcessMinidump::GetPluginName() { return GetPluginNameStatic(); }
 
 uint32_t ProcessMinidump::GetPluginVersion() { return 1; }
 
-Error ProcessMinidump::DoDestroy() { return Error::success(); }
+Error ProcessMinidump::DoDestroy() { return Error(); }
 
 void ProcessMinidump::RefreshStateAfterStop() {
   if (!m_active_exception)
index 07d5968..270400a 100644 (file)
@@ -172,7 +172,7 @@ Error Platform::GetFileWithUUID(const FileSpec &platform_file,
                                 const UUID *uuid_ptr, FileSpec &local_file) {
   // Default to the local case
   local_file = platform_file;
-  return Error::success();
+  return Error();
 }
 
 FileSpecList
@@ -1089,7 +1089,7 @@ Error Platform::KillProcess(const lldb::pid_t pid) {
         "they are controlled by a process plugin");
   }
   Host::Kill(pid, SIGTERM);
-  return Error::success();
+  return Error();
 }
 
 lldb::ProcessSP
@@ -1597,7 +1597,7 @@ Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
   const auto error = module_resolver(resolved_module_spec);
   if (error.Fail()) {
     if (GetCachedSharedModule(resolved_module_spec, module_sp, did_create_ptr))
-      return Error::success();
+      return Error();
   }
 
   return error;
index 60e1e33..67c1489 100644 (file)
@@ -3359,7 +3359,7 @@ Error Process::Halt(bool clear_thread_plans, bool use_run_lock) {
     RestoreProcessEvents();
     SetExitStatus(SIGKILL, "Cancelled async attach.");
     Destroy(false);
-    return Error::success();
+    return Error();
   }
 
   // Wait for 10 second for the process to stop.
@@ -3375,7 +3375,7 @@ Error Process::Halt(bool clear_thread_plans, bool use_run_lock) {
 
   BroadcastEvent(event_sp);
 
-  return Error::success();
+  return Error();
 }
 
 Error Process::StopForDestroyOrDetach(lldb::EventSP &exit_event_sp) {
index 4034ed3..8e2a9c7 100644 (file)
@@ -1766,7 +1766,7 @@ Error Thread::JumpToLine(const FileSpec &file, uint32_t line,
   if (!reg_ctx->SetPC(dest))
     return Error("Cannot change PC to target address.");
 
-  return Error::success();
+  return Error();
 }
 
 void Thread::DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
index c53be90..889cd8f 100644 (file)
@@ -70,7 +70,7 @@ Error MakeDirectory(const FileSpec &dir_path) {
     if (!dir_path.IsDirectory())
       return Error("Invalid existing path");
 
-    return Error::success();
+    return Error();
   }
 
   return FileSystem::MakeDirectory(dir_path, eFilePermissionsDirectoryDefault);
@@ -141,7 +141,7 @@ Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec,
                platform_module_spec.GetPath().c_str());
   if (sysroot_module_path_spec.Exists()) {
     if (!delete_existing)
-      return Error::success();
+      return Error();
 
     DecrementRefExistingModule(root_dir_spec, sysroot_module_path_spec);
   }
@@ -210,7 +210,7 @@ Error ModuleCache::Put(const FileSpec &root_dir_spec, const char *hostname,
   if (error.Fail())
     return Error("Failed to create link to %s: %s",
                  module_file_path.GetPath().c_str(), error.AsCString());
-  return Error::success();
+  return Error();
 }
 
 Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname,
@@ -221,7 +221,7 @@ Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname,
   if (find_it != m_loaded_modules.end()) {
     cached_module_sp = (*find_it).second.lock();
     if (cached_module_sp)
-      return Error::success();
+      return Error();
     m_loaded_modules.erase(find_it);
   }
 
@@ -263,7 +263,7 @@ Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname,
   m_loaded_modules.insert(
       std::make_pair(module_spec.GetUUID().GetAsString(), cached_module_sp));
 
-  return Error::success();
+  return Error();
 }
 
 Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec,
@@ -320,7 +320,7 @@ Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec,
     // module might
     // contain the necessary symbols and the debugging is also possible without
     // a symfile.
-    return Error::success();
+    return Error();
 
   error = Put(root_dir_spec, escaped_hostname.c_str(), module_spec,
               tmp_download_sym_file_spec,
@@ -332,5 +332,5 @@ Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec,
 
   FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec());
   cached_module_sp->SetSymbolFileFileSpec(symfile_spec);
-  return Error::success();
+  return Error();
 }
index 5bbe1ce..21d422c 100644 (file)
@@ -130,7 +130,7 @@ static Error save_socket_id_to_file(const std::string &socket_id,
                  file_spec.GetPath().c_str(), err_code.message().c_str());
 
   tmp_file_remover.releaseFile();
-  return Error::success();
+  return Error();
 }
 
 //----------------------------------------------------------------------
index eea26d1..911c278 100644 (file)
@@ -114,7 +114,7 @@ void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir,
         std::error_code ec = llvm::sys::fs::copy_file(
             s_test_executable, tmp_download_file_spec.GetCString());
         EXPECT_FALSE(ec);
-        return Error::success();
+        return Error();
       },
       [](const ModuleSP &module_sp, const FileSpec &tmp_download_file_spec) {
         return Error("Not supported.");
index e4f352a..a09a212 100644 (file)
@@ -27,6 +27,7 @@ namespace llvm {
 
 class Error;
 class ErrorList;
+class ErrorSuccess;
 
 /// Base class for error info classes. Do not extend this directly: Extend
 /// the ErrorInfo template subclass instead.
@@ -157,9 +158,8 @@ protected:
   }
 
 public:
-  /// Create a success value. This is equivalent to calling the default
-  /// constructor, but should be preferred for readability where possible.
-  static Error success() { return Error(); }
+  /// Create a success value.
+  static ErrorSuccess success();
 
   // Errors are not copy-constructable.
   Error(const Error &Other) = delete;
@@ -279,6 +279,13 @@ private:
   ErrorInfoBase *Payload;
 };
 
+/// Subclass of Error for the sole purpose of identifying the success path in
+/// the type system. This allows to catch invalid conversion to Expected<T> at
+/// compile time.
+class ErrorSuccess : public Error {};
+
+inline ErrorSuccess Error::success() { return ErrorSuccess(); }
+
 /// Make a Error instance representing failure using the given error info
 /// type.
 template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) {
@@ -645,6 +652,11 @@ public:
     new (getErrorStorage()) error_type(Err.takePayload());
   }
 
+  /// Forbid to convert from Error::success() implicitly, this avoids having
+  /// Expected<T> foo() { return Error::success(); } which compiles otherwise
+  /// but triggers the assertion above.
+  Expected(ErrorSuccess) = delete;
+
   /// Create an Expected<T> success value from the given OtherT value, which
   /// must be convertible to T.
   template <typename OtherT>
index d2c2ec7..270a1c4 100644 (file)
@@ -4330,7 +4330,7 @@ Expected<std::string> BitcodeReader::parseTriple() {
     case BitstreamEntry::Error:
       return error("Malformed block");
     case BitstreamEntry::EndBlock:
-      return Error::success();
+      return "";
 
     case BitstreamEntry::SubBlock:
       if (Entry.ID == bitc::MODULE_BLOCK_ID)
@@ -4363,14 +4363,14 @@ Expected<std::string> BitcodeReader::parseIdentificationBlock() {
     // we need to make sure we aren't at the end of the stream before calling
     // advance, otherwise we'll get an error.
     if (Stream.AtEndOfStream())
-      return Error::success();
+      return "";
 
     BitstreamEntry Entry = Stream.advance();
     switch (Entry.Kind) {
     case BitstreamEntry::Error:
       return error("Malformed block");
     case BitstreamEntry::EndBlock:
-      return Error::success();
+      return "";
 
     case BitstreamEntry::SubBlock:
       if (Entry.ID == bitc::IDENTIFICATION_BLOCK_ID) {
@@ -4421,7 +4421,7 @@ Expected<bool> BitcodeReader::hasObjCCategory() {
     case BitstreamEntry::Error:
       return error("Malformed block");
     case BitstreamEntry::EndBlock:
-      return Error::success();
+      return false;
 
     case BitstreamEntry::SubBlock:
       if (Entry.ID == bitc::MODULE_BLOCK_ID)
index 7468a85..1fe9017 100644 (file)
@@ -97,14 +97,15 @@ static void handleCustomErrorUPVoid(std::unique_ptr<CustomError> CE) {}
 // Test that success values implicitly convert to false, and don't cause crashes
 // once they've been implicitly converted.
 TEST(Error, CheckedSuccess) {
-  Error E;
+  Error E = Error::success();
   EXPECT_FALSE(E) << "Unexpected error while testing Error 'Success'";
 }
 
 // Test that unchecked succes values cause an abort.
 #ifndef NDEBUG
 TEST(Error, UncheckedSuccess) {
-  EXPECT_DEATH({ Error E; }, "Program aborted due to an unhandled Error:")
+  EXPECT_DEATH({ Error E = Error::success(); },
+               "Program aborted due to an unhandled Error:")
       << "Unchecked Error Succes value did not cause abort()";
 }
 #endif
@@ -121,7 +122,7 @@ void errAsOutParamHelper(Error &Err) {
 
 // Test that ErrorAsOutParameter sets the checked flag on construction.
 TEST(Error, ErrorAsOutParameterChecked) {
-  Error E;
+  Error E = Error::success();
   errAsOutParamHelper(E);
   (void)!!E;
 }
@@ -129,7 +130,7 @@ TEST(Error, ErrorAsOutParameterChecked) {
 // Test that ErrorAsOutParameter clears the checked flag on destruction.
 #ifndef NDEBUG
 TEST(Error, ErrorAsOutParameterUnchecked) {
-  EXPECT_DEATH({ Error E; errAsOutParamHelper(E); },
+  EXPECT_DEATH({ Error E = Error::success(); errAsOutParamHelper(E); },
                "Program aborted due to an unhandled Error:")
       << "ErrorAsOutParameter did not clear the checked flag on destruction.";
 }
@@ -197,31 +198,31 @@ TEST(Error, HandlerTypeDeduction) {
 
   handleAllErrors(
       make_error<CustomError>(42),
-      [](const CustomError &CE) mutable { return Error::success(); });
+      [](const CustomError &CE) mutable  -> Error { return Error::success(); });
 
   handleAllErrors(make_error<CustomError>(42),
                   [](const CustomError &CE) mutable {});
 
   handleAllErrors(make_error<CustomError>(42),
-                  [](CustomError &CE) { return Error::success(); });
+                  [](CustomError &CE) -> Error { return Error::success(); });
 
   handleAllErrors(make_error<CustomError>(42), [](CustomError &CE) {});
 
   handleAllErrors(make_error<CustomError>(42),
-                  [](CustomError &CE) mutable { return Error::success(); });
+                  [](CustomError &CE) mutable -> Error { return Error::success(); });
 
   handleAllErrors(make_error<CustomError>(42), [](CustomError &CE) mutable {});
 
   handleAllErrors(
       make_error<CustomError>(42),
-      [](std::unique_ptr<CustomError> CE) { return Error::success(); });
+      [](std::unique_ptr<CustomError> CE) -> Error { return Error::success(); });
 
   handleAllErrors(make_error<CustomError>(42),
                   [](std::unique_ptr<CustomError> CE) {});
 
   handleAllErrors(
       make_error<CustomError>(42),
-      [](std::unique_ptr<CustomError> CE) mutable { return Error::success(); });
+      [](std::unique_ptr<CustomError> CE) mutable -> Error { return Error::success(); });
 
   handleAllErrors(make_error<CustomError>(42),
                   [](std::unique_ptr<CustomError> CE) mutable {});
@@ -365,7 +366,7 @@ TEST(Error, CheckJoinErrors) {
 
 // Test that we can consume success values.
 TEST(Error, ConsumeSuccess) {
-  Error E;
+  Error E = Error::success();
   consumeError(std::move(E));
 }