[PATCH] D121665: [llvm-dis] Improve missing file error message
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 14 21:51:39 PDT 2022
keith created this revision.
Herald added a subscriber: ormris.
Herald added a project: All.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously the error message didn't include the failing path, which made
it hard to tell what went wrong.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121665
Files:
llvm/test/tools/llvm-dis/errors.test
llvm/tools/llvm-dis/llvm-dis.cpp
Index: llvm/tools/llvm-dis/llvm-dis.cpp
===================================================================
--- llvm/tools/llvm-dis/llvm-dis.cpp
+++ llvm/tools/llvm-dis/llvm-dis.cpp
@@ -180,8 +180,13 @@
}
for (std::string InputFilename : InputFilenames) {
- std::unique_ptr<MemoryBuffer> MB = ExitOnErr(
- errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
+ MemoryBuffer::getFileOrSTDIN(InputFilename);
+ if (std::error_code EC = BufferOrErr.getError()) {
+ WithColor::error() << InputFilename << ": " << EC.message() << '\n';
+ return 1;
+ }
+ std::unique_ptr<MemoryBuffer> MB = std::move(BufferOrErr.get());
BitcodeFileContents IF = ExitOnErr(llvm::getBitcodeFileContents(*MB));
Index: llvm/test/tools/llvm-dis/errors.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dis/errors.test
@@ -0,0 +1,3 @@
+# RUN: not llvm-dis missing-file-path 2>&1 | FileCheck %s --check-prefix=MISSING
+
+# MISSING: error: missing-file-path: No such file or directory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121665.415316.patch
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220315/19ee82ea/attachment-0001.bin>
More information about the llvm-commits
mailing list