[PATCH] D12846: [llvm-mc] Better error handling in ENOENT case + test
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 09:29:44 PDT 2015
davide created this revision.
davide added a reviewer: rafael.
davide added a subscriber: llvm-commits.
This is a follow up to r247518, addressing Rafael's post-commit reviews.
As a general note, I think we could do a much better job testing for error conditions in tools. I already anticipated in a previous mail, but while implementing this I noticed that the code coverage we have for this is pretty low. I can arbitrarily remove error checking from various tests and the suite still passes.
http://reviews.llvm.org/D12846
Files:
test/tools/llvm-mc/basic.test
tools/llvm-mc/llvm-mc.cpp
Index: tools/llvm-mc/llvm-mc.cpp
===================================================================
--- tools/llvm-mc/llvm-mc.cpp
+++ tools/llvm-mc/llvm-mc.cpp
@@ -395,15 +395,10 @@
// construct the Triple object.
Triple TheTriple(TripleName);
- if (InputFilename != "-" && !sys::fs::exists(InputFilename)) {
- errs() << ProgName << ": '" << InputFilename << "': "
- << "No such file\n";
- return 1;
- }
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferPtr.getError()) {
- errs() << ProgName << ": " << EC.message() << '\n';
+ errs() << InputFilename << ": " << EC.message() << '\n';
return 1;
}
MemoryBuffer *Buffer = BufferPtr->get();
Index: test/tools/llvm-mc/basic.test
===================================================================
--- test/tools/llvm-mc/basic.test
+++ test/tools/llvm-mc/basic.test
@@ -0,0 +1,2 @@
+# RUN: not llvm-mc %t.blah -o %t2 2>&1 | FileCheck --check-prefix=ENOENT %s
+# ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12846.34691.patch
Type: text/x-patch
Size: 1095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150914/15276c6a/attachment.bin>
More information about the llvm-commits
mailing list