[llvm] [llvm-objcopy] Fix prints wrong path when section output path doesn't exist (PR #125345)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 00:52:10 PST 2025
================
@@ -186,27 +186,32 @@ static std::unique_ptr<Writer> createWriter(const CommonConfig &Config,
}
static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
- Object &Obj) {
+ StringRef InputFilename, Object &Obj) {
for (auto &Sec : Obj.sections()) {
if (Sec.Name == SecName) {
- if (Sec.Type == SHT_NOBITS)
- return createStringError(object_error::parse_failed,
- "cannot dump section '%s': it has no contents",
- SecName.str().c_str());
+ if (Sec.Type == SHT_NOBITS) {
+ Error E =
+ createStringError(object_error::parse_failed,
+ "cannot dump section '%s': it has no contents",
+ SecName.str().c_str());
+ return createFileError(InputFilename, std::move(E));
----------------
jh7370 wrote:
This is a common pattern throughout this change (i.e. `createStringError` followed immediately by `createFileError`). Would it make sense to create a little helper function (either locally or in Error.h) that is equivalent to the two chained together?
https://github.com/llvm/llvm-project/pull/125345
More information about the llvm-commits
mailing list