Skip to content

llvm-readobj: Use reportFatalUsageError #142039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-readobj/COFF/arm64-many-epilogs.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: aarch64-registered-target
// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o - \
// RUN: | not --crash llvm-readobj --unwind - 2>&1 | FileCheck %s
// RUN: | not llvm-readobj --unwind - 2>&1 | FileCheck %s

// Older versions of LLVM had a bug where we would accidentally
// truncate the number of epilogue scopes to a uint8_t; make
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-readobj/COFF/arm64-win-error2.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// REQUIRES: aarch64-registered-target
// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o - \
// RUN: | not --crash llvm-readobj --unwind - 2>&1 | FileCheck %s
// RUN: | not llvm-readobj --unwind - 2>&1 | FileCheck %s

// CHECK: LLVM ERROR: Malformed unwind data

Expand Down
16 changes: 8 additions & 8 deletions llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ ErrorOr<SymbolRef> Decoder::getSymbolForLocation(
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(AddressOrErr.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}
// We apply SymbolOffset here directly. We return it separately to allow
// the caller to print it as an offset on the symbol name.
Expand Down Expand Up @@ -1094,7 +1094,7 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
// A header is one or two words, followed by at least one word to describe
// the unwind codes. Applicable to both ARM and AArch64.
if (Contents.size() - Offset < 8)
report_fatal_error(".xdata must be at least 8 bytes in size");
reportFatalUsageError(".xdata must be at least 8 bytes in size");

const ExceptionDataRecord XData(Data, isAArch64);
DictScope XRS(SW, "ExceptionData");
Expand All @@ -1115,7 +1115,7 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
(XData.E() ? 0 : XData.EpilogueCount() * 4) -
(XData.X() ? 8 : 0)) < (int64_t)ByteCodeLength) {
SW.flush();
report_fatal_error("Malformed unwind data");
reportFatalUsageError("Malformed unwind data");
}

if (XData.E()) {
Expand Down Expand Up @@ -1178,7 +1178,7 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(Name.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}

ListScope EHS(SW, "ExceptionHandler");
Expand Down Expand Up @@ -1217,7 +1217,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
Expand All @@ -1231,7 +1231,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(Name.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}

SW.printString("ExceptionRecord",
Expand Down Expand Up @@ -1276,7 +1276,7 @@ bool Decoder::dumpPackedEntry(const object::COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
Expand Down Expand Up @@ -1375,7 +1375,7 @@ bool Decoder::dumpPackedARM64Entry(const object::COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
report_fatal_error(Twine(Buf));
reportFatalUsageError(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
Expand Down
Loading