[PATCH] D12846: [llvm-mc] Better error handling in ENOENT case + test
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 10:02:29 PDT 2015
Lgtm! Thanks
On Sep 14, 2015 12:30 PM, "Davide Italiano" <dccitaliano at gmail.com> wrote:
> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150914/ac80287c/attachment.html>
More information about the llvm-commits
mailing list