[llvm] r286561 - Make the Error class constructor protected
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 20:28:43 PST 2016
Author: mehdi_amini
Date: Thu Nov 10 22:28:40 2016
New Revision: 286561
URL: http://llvm.org/viewvc/llvm-project?rev=286561&view=rev
Log:
Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority
of cases a lot more readable.
Differential Revision: https://reviews.llvm.org/D26481
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
llvm/trunk/include/llvm/Support/Error.h
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/LTO/LTOBackend.cpp
llvm/trunk/lib/Object/Archive.cpp
llvm/trunk/lib/Object/Error.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/MachOUniversal.cpp
llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/trunk/tools/dsymutil/BinaryHolder.cpp
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
llvm/trunk/tools/llvm-size/llvm-size.cpp
llvm/trunk/tools/llvm-xray/xray-extract.cc
llvm/trunk/tools/sancov/sancov.cc
llvm/trunk/unittests/Support/ErrorTest.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h Thu Nov 10 22:28:40 2016
@@ -589,7 +589,7 @@ public:
/// Channel is the ChannelT instance to communicate on. It is assumed that
/// the channel is ready to be read from and written to.
static Expected<OrcRemoteTargetClient> Create(ChannelT &Channel) {
- Error Err;
+ Error Err = Error::success();
OrcRemoteTargetClient H(Channel, Err);
if (Err)
return std::move(Err);
@@ -808,7 +808,7 @@ private:
static Error doNothing() { return Error::success(); }
ChannelT &Channel;
- Error ExistingError;
+ Error ExistingError = Error::success();
std::string RemoteTargetTriple;
uint32_t RemotePointerSize = 0;
uint32_t RemotePageSize = 0;
Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Thu Nov 10 22:28:40 2016
@@ -149,14 +149,14 @@ class LLVM_NODISCARD Error {
// error.
template <typename T> friend class Expected;
-public:
+protected:
/// Create a success value. Prefer using 'Error::success()' for readability
- /// where possible.
Error() : Payload(nullptr) {
setPtr(nullptr);
setChecked(false);
}
+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(); }
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Thu Nov 10 22:28:40 2016
@@ -437,7 +437,7 @@ Error LTO::addThinLTO(std::unique_ptr<In
assert(ResI == Res.end());
ThinLTO.ModuleMap[MBRef.getBufferIdentifier()] = MBRef;
- return Error();
+ return Error::success();
}
unsigned LTO::getMaxTasks() const {
@@ -489,7 +489,7 @@ Error LTO::runRegularLTO(AddStreamFn Add
if (Conf.PreOptModuleHook &&
!Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule))
- return Error();
+ return Error::success();
if (!Conf.CodeGenOnly) {
for (const auto &R : GlobalResolutions) {
@@ -512,7 +512,7 @@ Error LTO::runRegularLTO(AddStreamFn Add
if (Conf.PostInternalizeModuleHook &&
!Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
- return Error();
+ return Error::success();
}
return backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel,
std::move(RegularLTO.CombinedModule));
@@ -593,7 +593,7 @@ public:
if (AddStreamFn CacheAddStream = Cache(Task, Key))
return RunThinBackend(CacheAddStream);
- return Error();
+ return Error::success();
}
Error start(
@@ -628,7 +628,7 @@ public:
MBRef, std::ref(CombinedIndex), std::ref(ImportList),
std::ref(ExportList), std::ref(ResolvedODR), std::ref(DefinedGlobals),
std::ref(ModuleMap));
- return Error();
+ return Error::success();
}
Error wait() override {
@@ -636,7 +636,7 @@ public:
if (Err)
return std::move(*Err);
else
- return Error();
+ return Error::success();
}
};
@@ -722,10 +722,10 @@ public:
if (ShouldEmitImportsFiles)
return errorCodeToError(
EmitImportsFiles(ModulePath, NewModulePath + ".imports", ImportList));
- return Error();
+ return Error::success();
}
- Error wait() override { return Error(); }
+ Error wait() override { return Error::success(); }
};
ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix,
@@ -744,10 +744,10 @@ ThinBackend lto::createWriteIndexesThinB
Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
bool HasRegularLTO) {
if (ThinLTO.ModuleMap.empty())
- return Error();
+ return Error::success();
if (Conf.CombinedIndexHook && !Conf.CombinedIndexHook(ThinLTO.CombinedIndex))
- return Error();
+ return Error::success();
// Collect for each module the list of function it defines (GUID ->
// Summary).
Modified: llvm/trunk/lib/LTO/LTOBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOBackend.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp (original)
+++ llvm/trunk/lib/LTO/LTOBackend.cpp Thu Nov 10 22:28:40 2016
@@ -105,7 +105,7 @@ Error Config::addSaveTemps(std::string O
return true;
};
- return Error();
+ return Error::success();
}
namespace {
@@ -302,7 +302,7 @@ Error lto::backend(Config &C, AddStreamF
if (!C.CodeGenOnly)
if (!opt(C, TM.get(), 0, *Mod, /*IsThinLto=*/false))
- return Error();
+ return Error::success();
if (ParallelCodeGenParallelismLevel == 1) {
codegen(C, TM.get(), AddStream, 0, *Mod);
@@ -310,7 +310,7 @@ Error lto::backend(Config &C, AddStreamF
splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel,
std::move(Mod));
}
- return Error();
+ return Error::success();
}
Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
@@ -329,25 +329,25 @@ Error lto::thinBackend(Config &Conf, uns
if (Conf.CodeGenOnly) {
codegen(Conf, TM.get(), AddStream, Task, Mod);
- return Error();
+ return Error::success();
}
if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod))
- return Error();
+ return Error::success();
renameModuleForThinLTO(Mod, CombinedIndex);
thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals);
if (Conf.PostPromoteModuleHook && !Conf.PostPromoteModuleHook(Task, Mod))
- return Error();
+ return Error::success();
if (!DefinedGlobals.empty())
thinLTOInternalizeModule(Mod, DefinedGlobals);
if (Conf.PostInternalizeModuleHook &&
!Conf.PostInternalizeModuleHook(Task, Mod))
- return Error();
+ return Error::success();
auto ModuleLoader = [&](StringRef Identifier) {
assert(Mod.getContext().isODRUniquingDebugTypes() &&
@@ -363,11 +363,11 @@ Error lto::thinBackend(Config &Conf, uns
return Err;
if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod))
- return Error();
+ return Error::success();
if (!opt(Conf, TM.get(), Task, Mod, /*IsThinLto=*/true))
- return Error();
+ return Error::success();
codegen(Conf, TM.get(), AddStream, Task, Mod);
- return Error();
+ return Error::success();
}
Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Thu Nov 10 22:28:40 2016
@@ -458,7 +458,7 @@ Expected<Archive::Child> Archive::Child:
return malformedError(Msg + NameOrErr.get());
}
- Error Err;
+ Error Err = Error::success();
Child Ret(Parent, NextLoc, &Err);
if (Err)
return std::move(Err);
@@ -508,7 +508,7 @@ Archive::Child::getAsBinary(LLVMContext
}
Expected<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
- Error Err;
+ Error Err = Error::success();
std::unique_ptr<Archive> Ret(new Archive(Source, Err));
if (Err)
return std::move(Err);
@@ -830,7 +830,7 @@ Expected<Archive::Child> Archive::Symbol
}
const char *Loc = Parent->getData().begin() + Offset;
- Error Err;
+ Error Err = Error::success();
Child C(Parent, Loc, &Err);
if (Err)
return std::move(Err);
Modified: llvm/trunk/lib/Object/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Error.cpp (original)
+++ llvm/trunk/lib/Object/Error.cpp Thu Nov 10 22:28:40 2016
@@ -79,18 +79,17 @@ const std::error_category &object::objec
llvm::Error llvm::object::isNotObjectErrorInvalidFileType(llvm::Error Err) {
if (auto Err2 =
- handleErrors(std::move(Err),
- [](std::unique_ptr<ECError> M) {
- // Try to handle 'M'. If successful, return a success value from
- // the handler.
- if (M->convertToErrorCode() == object_error::invalid_file_type)
- return Error::success();
+ handleErrors(std::move(Err), [](std::unique_ptr<ECError> M) -> Error {
+ // Try to handle 'M'. If successful, return a success value from
+ // the handler.
+ if (M->convertToErrorCode() == object_error::invalid_file_type)
+ return Error::success();
- // We failed to handle 'M' - return it from the handler.
- // This value will be passed back from catchErrors and
- // wind up in Err2, where it will be returned from this function.
- return Error(std::move(M));
- }))
+ // We failed to handle 'M' - return it from the handler.
+ // This value will be passed back from catchErrors and
+ // wind up in Err2, where it will be returned from this function.
+ return Error(std::move(M));
+ }))
return Err2;
return Err;
}
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Nov 10 22:28:40 2016
@@ -1073,7 +1073,7 @@ Expected<std::unique_ptr<MachOObjectFile
MachOObjectFile::create(MemoryBufferRef Object, bool IsLittleEndian,
bool Is64Bits, uint32_t UniversalCputype,
uint32_t UniversalIndex) {
- Error Err;
+ Error Err = Error::success();
std::unique_ptr<MachOObjectFile> Obj(
new MachOObjectFile(std::move(Object), IsLittleEndian,
Is64Bits, Err, UniversalCputype,
Modified: llvm/trunk/lib/Object/MachOUniversal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOUniversal.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOUniversal.cpp (original)
+++ llvm/trunk/lib/Object/MachOUniversal.cpp Thu Nov 10 22:28:40 2016
@@ -107,7 +107,7 @@ void MachOUniversalBinary::anchor() { }
Expected<std::unique_ptr<MachOUniversalBinary>>
MachOUniversalBinary::create(MemoryBufferRef Source) {
- Error Err;
+ Error Err = Error::success();
std::unique_ptr<MachOUniversalBinary> Ret(
new MachOUniversalBinary(Source, Err));
if (Err)
Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp Thu Nov 10 22:28:40 2016
@@ -648,7 +648,7 @@ BinaryCoverageReader::create(std::unique
StringRef Coverage;
uint8_t BytesInAddress;
support::endianness Endian;
- Error E;
+ Error E = Error::success();
consumeError(std::move(E));
if (ObjectBuffer->getBuffer().startswith(TestingFormatMagic))
// This is a special format used for testing.
Modified: llvm/trunk/tools/dsymutil/BinaryHolder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/BinaryHolder.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/BinaryHolder.cpp (original)
+++ llvm/trunk/tools/dsymutil/BinaryHolder.cpp Thu Nov 10 22:28:40 2016
@@ -100,7 +100,7 @@ ErrorOr<std::vector<MemoryBufferRef>> Bi
Buffers.reserve(CurrentArchives.size());
for (const auto &CurrentArchive : CurrentArchives) {
- Error Err;
+ Error Err = Error::success();
for (auto Child : CurrentArchive->children(Err)) {
if (auto NameOrErr = Child.getName()) {
if (*NameOrErr == Filename) {
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Nov 10 22:28:40 2016
@@ -423,7 +423,7 @@ static void performReadOperation(Archive
bool Filter = !Members.empty();
{
- Error Err;
+ Error Err = Error::success();
for (auto &C : OldArchive->children(Err)) {
Expected<StringRef> NameOrErr = C.getName();
failIfError(NameOrErr.takeError());
@@ -551,7 +551,7 @@ computeNewArchiveMembers(ArchiveOperatio
int InsertPos = -1;
StringRef PosName = sys::path::filename(RelPos);
if (OldArchive) {
- Error Err;
+ Error Err = Error::success();
for (auto &Child : OldArchive->children(Err)) {
int Pos = Ret.size();
Expected<StringRef> NameOrErr = Child.getName();
@@ -723,7 +723,7 @@ static int performOperation(ArchiveOpera
fail("error opening '" + ArchiveName + "': " + EC.message() + "!");
if (!EC) {
- Error Err;
+ Error Err = Error::success();
object::Archive Archive(Buf.get()->getMemBufferRef(), Err);
EC = errorToErrorCode(std::move(Err));
failIfError(EC,
@@ -785,7 +785,7 @@ static void runMRIScript() {
Archives.push_back(std::move(*LibOrErr));
object::Archive &Lib = *Archives.back();
{
- Error Err;
+ Error Err = Error::success();
for (auto &Member : Lib.children(Err))
addMember(NewMembers, Member);
failIfError(std::move(Err));
Modified: llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp (original)
+++ llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp Thu Nov 10 22:28:40 2016
@@ -490,7 +490,7 @@ static void dumpCXXData(const ObjectFile
}
static void dumpArchive(const Archive *Arc) {
- Error Err;
+ Error Err = Error::success();
for (auto &ArcC : Arc->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = ArcC.getAsBinary();
if (!ChildOrErr) {
Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Thu Nov 10 22:28:40 2016
@@ -364,7 +364,7 @@ static Error handleCompressedSection(
std::deque<SmallString<32>> &UncompressedSections, StringRef &Name,
StringRef &Contents) {
if (!Name.startswith("zdebug_"))
- return Error();
+ return Error::success();
UncompressedSections.emplace_back();
uint64_t OriginalSize;
if (!zlib::isAvailable())
@@ -377,7 +377,7 @@ static Error handleCompressedSection(
.str());
Name = Name.substr(1);
Contents = UncompressedSections.back();
- return Error();
+ return Error::success();
}
static Error handleSection(
@@ -392,10 +392,10 @@ static Error handleSection(
StringRef &AbbrevSection, StringRef &CurCUIndexSection,
StringRef &CurTUIndexSection) {
if (Section.isBSS())
- return Error();
+ return Error::success();
if (Section.isVirtual())
- return Error();
+ return Error::success();
StringRef Name;
if (std::error_code Err = Section.getName(Name))
@@ -412,7 +412,7 @@ static Error handleSection(
auto SectionPair = KnownSections.find(Name);
if (SectionPair == KnownSections.end())
- return Error();
+ return Error::success();
if (DWARFSectionKind Kind = SectionPair->second.second) {
auto Index = Kind - DW_SECT_INFO;
@@ -449,7 +449,7 @@ static Error handleSection(
Out.SwitchSection(OutSection);
Out.EmitBytes(Contents);
}
- return Error();
+ return Error::success();
}
static Error
@@ -600,7 +600,7 @@ static Error write(MCStreamer &Out, Arra
writeIndex(Out, MCOFI.getDwarfCUIndexSection(), ContributionOffsets,
IndexEntries);
- return Error();
+ return Error::success();
}
static int error(const Twine &Error, const Twine &Context) {
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Nov 10 22:28:40 2016
@@ -1113,7 +1113,7 @@ static void dumpSymbolNamesFromFile(std:
}
{
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(&Context);
if (!ChildOrErr) {
@@ -1178,7 +1178,7 @@ static void dumpSymbolNamesFromFile(std:
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
I->getAsArchive()) {
std::unique_ptr<Archive> &A = *AOrErr;
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr =
C.getAsBinary(&Context);
@@ -1249,7 +1249,7 @@ static void dumpSymbolNamesFromFile(std:
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
I->getAsArchive()) {
std::unique_ptr<Archive> &A = *AOrErr;
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr =
C.getAsBinary(&Context);
@@ -1316,7 +1316,7 @@ static void dumpSymbolNamesFromFile(std:
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
I->getAsArchive()) {
std::unique_ptr<Archive> &A = *AOrErr;
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr =
C.getAsBinary(&Context);
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Thu Nov 10 22:28:40 2016
@@ -1546,7 +1546,8 @@ static void printArchiveChild(StringRef
static void printArchiveHeaders(StringRef Filename, Archive *A, bool verbose,
bool print_offset,
StringRef ArchitectureName = StringRef()) {
- Error Err;
+ Error Err = Error::success();
+ ;
for (const auto &C : A->children(Err, false))
printArchiveChild(Filename, C, verbose, print_offset, ArchitectureName);
@@ -1583,7 +1584,7 @@ void llvm::ParseInputMachO(StringRef Fil
if (ArchiveHeaders)
printArchiveHeaders(Filename, A, !NonVerbose, ArchiveMemberOffsets);
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -1641,7 +1642,7 @@ void llvm::ParseInputMachO(StringRef Fil
if (ArchiveHeaders)
printArchiveHeaders(Filename, A.get(), !NonVerbose,
ArchiveMemberOffsets, ArchitectureName);
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -1697,7 +1698,7 @@ void llvm::ParseInputMachO(StringRef Fil
if (ArchiveHeaders)
printArchiveHeaders(Filename, A.get(), !NonVerbose,
ArchiveMemberOffsets);
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -1749,7 +1750,7 @@ void llvm::ParseInputMachO(StringRef Fil
if (ArchiveHeaders)
printArchiveHeaders(Filename, A.get(), !NonVerbose,
ArchiveMemberOffsets, ArchitectureName);
- Error Err;
+ Error Err = Error::success();
for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu Nov 10 22:28:40 2016
@@ -1969,7 +1969,7 @@ static void DumpObject(const COFFImportF
/// @brief Dump each object file in \a a;
static void DumpArchive(const Archive *a) {
- Error Err;
+ Error Err = Error::success();
for (auto &C : a->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Thu Nov 10 22:28:40 2016
@@ -458,7 +458,7 @@ static void dumpObject(const ObjectFile
/// @brief Dumps each object file in \a Arc;
static void dumpArchive(const Archive *Arc) {
- Error Err;
+ Error Err = Error::success();
for (auto &Child : Arc->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
if (!ChildOrErr) {
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Thu Nov 10 22:28:40 2016
@@ -542,7 +542,7 @@ static void printFileSectionSizes(String
if (Archive *a = dyn_cast<Archive>(&Bin)) {
// This is an archive. Iterate over each member and display its sizes.
- Error Err;
+ Error Err = Error::success();
for (auto &C : a->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -611,7 +611,7 @@ static void printFileSectionSizes(String
std::unique_ptr<Archive> &UA = *AOrErr;
// This is an archive. Iterate over each member and display its
// sizes.
- Error Err;
+ Error Err = Error::success();
for (auto &C : UA->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -700,7 +700,7 @@ static void printFileSectionSizes(String
std::unique_ptr<Archive> &UA = *AOrErr;
// This is an archive. Iterate over each member and display its
// sizes.
- Error Err;
+ Error Err = Error::success();
for (auto &C : UA->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
@@ -775,7 +775,7 @@ static void printFileSectionSizes(String
I->getAsArchive()) {
std::unique_ptr<Archive> &UA = *AOrErr;
// This is an archive. Iterate over each member and display its sizes.
- Error Err;
+ Error Err = Error::success();
for (auto &C : UA->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
Modified: llvm/trunk/tools/llvm-xray/xray-extract.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-xray/xray-extract.cc?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-xray/xray-extract.cc (original)
+++ llvm/trunk/tools/llvm-xray/xray-extract.cc Thu Nov 10 22:28:40 2016
@@ -223,8 +223,8 @@ void InstrumentationMapExtractor::export
Out << YAMLSleds;
}
-static CommandRegistration Unused(&Extract, [] {
- Error Err;
+static CommandRegistration Unused(&Extract, []() -> Error {
+ Error Err = Error::success();
xray::InstrumentationMapExtractor Extractor(
ExtractInput, InstrumentationMapExtractor::InputFormats::ELF, Err);
if (Err)
Modified: llvm/trunk/tools/sancov/sancov.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sancov/sancov.cc?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/tools/sancov/sancov.cc (original)
+++ llvm/trunk/tools/sancov/sancov.cc Thu Nov 10 22:28:40 2016
@@ -821,7 +821,7 @@ static void getObjectCoveragePoints(cons
static void
visitObjectFiles(const object::Archive &A,
function_ref<void(const object::ObjectFile &)> Fn) {
- Error Err;
+ Error Err = Error::success();
for (auto &C : A.children(Err)) {
Expected<std::unique_ptr<object::Binary>> ChildOrErr = C.getAsBinary();
failIfError(ChildOrErr);
Modified: llvm/trunk/unittests/Support/ErrorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorTest.cpp?rev=286561&r1=286560&r2=286561&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ErrorTest.cpp (original)
+++ llvm/trunk/unittests/Support/ErrorTest.cpp Thu Nov 10 22:28:40 2016
@@ -82,12 +82,14 @@ protected:
char CustomSubError::ID = 0;
-static Error handleCustomError(const CustomError &CE) { return Error(); }
+static Error handleCustomError(const CustomError &CE) {
+ return Error::success();
+}
static void handleCustomErrorVoid(const CustomError &CE) {}
static Error handleCustomErrorUP(std::unique_ptr<CustomError> CE) {
- return Error();
+ return Error::success();
}
static void handleCustomErrorUPVoid(std::unique_ptr<CustomError> CE) {}
More information about the llvm-commits
mailing list