[PATCH] D133549: [llvm-dwp] Report the filename if it cannot be found
Qing Shan Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 8 19:34:54 PDT 2022
steven.zhang created this revision.
steven.zhang added reviewers: dblaikie, grimar, alexander-shaposhnikov.
Herald added a subscriber: hiraditya.
Herald added a project: All.
steven.zhang requested review of this revision.
Herald added a project: LLVM.
For now, we report nothing if the execution/dwo file is missing, which is confusing.
llvm-dwp -e a.out1 -o y
error: No such file or directory
With this patch, it looks like this:
llvm-dwp -e a.out1 -o y
error: 'a.out1': No such file or directory
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133549
Files:
llvm/lib/DWP/DWP.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===================================================================
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -111,7 +111,13 @@
for (const auto &ExecFilename : ExecFilenames) {
auto DWOs = getDWOFilenames(ExecFilename);
if (!DWOs) {
- logAllUnhandledErrors(DWOs.takeError(), WithColor::error());
+ logAllUnhandledErrors(
+ handleErrors(DWOs.takeError(),
+ [&](std::unique_ptr<ECError> EC) -> Error {
+ return createFileError(ExecFilename,
+ Error(std::move(EC)));
+ }),
+ WithColor::error());
return 1;
}
DWOFilenames.insert(DWOFilenames.end(),
@@ -127,7 +133,13 @@
auto ErrOrTriple = readTargetTriple(DWOFilenames.front());
if (!ErrOrTriple) {
- logAllUnhandledErrors(ErrOrTriple.takeError(), WithColor::error());
+ logAllUnhandledErrors(
+ handleErrors(ErrOrTriple.takeError(),
+ [&](std::unique_ptr<ECError> EC) -> Error {
+ return createFileError(DWOFilenames.front(),
+ Error(std::move(EC)));
+ }),
+ WithColor::error());
return 1;
}
Index: llvm/lib/DWP/DWP.cpp
===================================================================
--- llvm/lib/DWP/DWP.cpp
+++ llvm/lib/DWP/DWP.cpp
@@ -586,8 +586,12 @@
for (const auto &Input : Inputs) {
auto ErrOrObj = object::ObjectFile::createObjectFile(Input);
- if (!ErrOrObj)
- return ErrOrObj.takeError();
+ if (!ErrOrObj) {
+ return handleErrors(ErrOrObj.takeError(),
+ [&](std::unique_ptr<ECError> EC) -> Error {
+ return createFileError(Input, Error(std::move(EC)));
+ });
+ }
auto &Obj = *ErrOrObj->getBinary();
Objects.push_back(std::move(*ErrOrObj));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133549.458947.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220909/687d44f9/attachment.bin>
More information about the llvm-commits
mailing list