[llvm] r247582 - [llvm-mc] Better error handling in ENOENT case + test.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 10:10:02 PDT 2015
Author: davide
Date: Mon Sep 14 12:10:01 2015
New Revision: 247582
URL: http://llvm.org/viewvc/llvm-project?rev=247582&view=rev
Log:
[llvm-mc] Better error handling in ENOENT case + test.
This is a follow up to r247518.
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 error checking is pretty low. I can arbitrarily remove checks from
several tools and the suite still passes.
Differential Revision: http://reviews.llvm.org/D12846
Added:
llvm/trunk/test/tools/llvm-mc/basic.test
Modified:
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Added: llvm/trunk/test/tools/llvm-mc/basic.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-mc/basic.test?rev=247582&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-mc/basic.test (added)
+++ llvm/trunk/test/tools/llvm-mc/basic.test Mon Sep 14 12:10:01 2015
@@ -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
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=247582&r1=247581&r2=247582&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Mon Sep 14 12:10:01 2015
@@ -395,15 +395,10 @@ int main(int argc, char **argv) {
// 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();
More information about the llvm-commits
mailing list