[PATCH] D42222: [llvm-objcopy] Refactor llvm-objcopy to use reader and writer objects

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 12:25:08 PST 2018


jakehehrlich added a comment.

In https://reviews.llvm.org/D42222#986138, @jhenderson wrote:

> One small inline comment. Otherwise, I'm happy with this as-is. Are you still planning on splitting it up? It'll make it somewhat easier, I hope to spot any problems, but if it's a lot of extra work, may no longer be worth it.


It's a lot of work to split it up. I'd rather not.



================
Comment at: test/tools/llvm-objcopy/binary-out-error.test:1
+# RUN: not llvm-objcopy -O binary %p/Inputs/alloc-symtab.o %t2 2>&1 >/dev/null | FileCheck %s --check-prefix=SYMTAB
+# SYMTAB: Cannot write symbol table '.symtab' out to binary
----------------
jhenderson wrote:
> What's going on with the "/dev/null" here?
We need to throw an error but that error is written to stderr not stdout but the pipe only pipes stdout to FileCheck. So we redirect stderr (2) to where stdout is going (&1) and then we redirect stdout to /dev/null so nothing comes from stdout (because as is both stderr and stdout would be pipped to FileCheck).

In this case it doesn't matter but I copy-pasted this from other code that checks errors and that come along with it. It's part of the standard way of checking error messages in lit tests. Run "git grep /dev/null | wc -l" in the test directory. I get 1113 uses but not all of those are to suppress stdout, some suppress stderr.


Repository:
  rL LLVM

https://reviews.llvm.org/D42222





More information about the llvm-commits mailing list