[PATCH] D104483: Improve error handling in llvm-dwarfdump
Adrian Prantl via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 22 16:20:04 PDT 2021
aprantl updated this revision to Diff 353814.
aprantl added a comment.
Thanks, this is much cleaner!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104483/new/
https://reviews.llvm.org/D104483
Files:
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Index: llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
===================================================================
--- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -263,29 +263,15 @@
/// @}
//===----------------------------------------------------------------------===//
-static void error(StringRef Prefix, std::error_code EC,
- llvm::Optional<std::string> Msg = {}) {
- if (!EC)
+static void error(StringRef Prefix, Error Err) {
+ if (!Err)
return;
- WithColor::error() << Prefix << ": " << (Msg ? *Msg : EC.message()) << '\n';
- exit(1);
+ WithColor::error() << Prefix << ": " << toString(std::move(Err)) << "\n";
+ exit(1);
}
-static void error(StringRef Prefix, Error Err) {
- std::error_code EC;
- llvm::Optional<std::string> Msg;
- handleAllErrors(
- std::move(Err),
- [&](const GenericBinaryError &E) {
- Msg = E.getMessage();
- EC = E.convertToErrorCode();
- },
- [&](const StringError &E) {
- Msg = E.getMessage();
- EC = E.convertToErrorCode();
- },
- [&](const ECError &E) { EC = E.convertToErrorCode(); });
- error(Prefix, EC, Msg);
+static void error(StringRef Prefix, std::error_code EC) {
+ error(Prefix, errorCodeToError(EC));
}
static DIDumpOptions getDumpOpts(DWARFContext &C) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104483.353814.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210622/84807f61/attachment.bin>
More information about the llvm-commits
mailing list