[PATCH] D113305: Remove unnecessary conditionals around errors.
Roger Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 5 12:20:43 PDT 2021
Roger created this revision.
Roger added a reviewer: jhenderson.
Roger requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The existing code has unnecessary logic to indirectly pass
errors through function calls. This diff gets rid of the fluff.
Test Plan: Existing unit tests
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113305
Files:
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
Index: llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
===================================================================
--- llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -309,10 +309,7 @@
if (Magic == file_magic::bitcode)
return verifyAndAddIRObject(Members, std::move(*NMOrErr), C);
- if (Error E = verifyAndAddMachOObject(Members, std::move(*NMOrErr), C))
- return E;
-
- return Error::success();
+ return verifyAndAddMachOObject(Members, std::move(*NMOrErr), C);
}
static Error processArchive(MembersPerArchitectureMap &Members,
@@ -441,9 +438,7 @@
if (Magic == file_magic::bitcode)
return verifyAndAddIRObject(Members, std::move(*NMOrErr), C);
- if (Error E = verifyAndAddMachOObject(Members, std::move(*NMOrErr), C))
- return E;
- return Error::success();
+ return verifyAndAddMachOObject(Members, std::move(*NMOrErr), C);
}
static Expected<SmallVector<Slice, 2>>
@@ -477,12 +472,10 @@
}
if (NewMembers.size() == 1) {
- if (Error E =
- writeArchive(OutputFile, NewMembers.begin()->second,
- /*WriteSymtab=*/true,
- /*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
- /*Thin=*/false))
- return E;
+ return writeArchive(OutputFile, NewMembers.begin()->second,
+ /*WriteSymtab=*/true,
+ /*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
+ /*Thin=*/false);
} else {
SmallVector<OwningBinary<Archive>, 2> OutputBinaries;
for (const std::pair<const uint64_t, std::vector<NewArchiveMember>> &M :
@@ -512,10 +505,8 @@
return Slices.takeError();
llvm::stable_sort(*Slices);
- if (Error E = writeUniversalBinary(*Slices, OutputFile))
- return E;
+ return writeUniversalBinary(*Slices, OutputFile);
}
- return Error::success();
}
static Expected<Config> parseCommandLine(int Argc, char **Argv) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113305.385149.patch
Type: text/x-patch
Size: 2034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211105/a30b30f7/attachment.bin>
More information about the llvm-commits
mailing list