diff --git a/test/tools/llvm-size/basic.test b/test/tools/llvm-size/basic.test index 614c6394027..88b8dcbcbff 100644 --- a/test/tools/llvm-size/basic.test +++ b/test/tools/llvm-size/basic.test @@ -1,2 +1,2 @@ -RUN: llvm-size %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s +RUN: not llvm-size %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s ENOENT: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: error reading file: {{[Nn]}}o such file or directory diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index 1be173bdf54..e3b487c388f 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -84,6 +84,8 @@ RadixShort(cl::desc("Print size in radix:"), static cl::list InputFilenames(cl::Positional, cl::desc(""), cl::ZeroOrMore); +bool HadError = false; + static std::string ToolName; /// If ec is not success, print the error and return true. @@ -91,6 +93,7 @@ static bool error(std::error_code ec) { if (!ec) return false; + HadError = true; errs() << ToolName << ": error reading file: " << ec.message() << ".\n"; errs().flush(); return true; @@ -757,5 +760,6 @@ int main(int argc, char **argv) { std::for_each(InputFilenames.begin(), InputFilenames.end(), printFileSectionSizes); - return 0; + if (HadError) + return 1; }