From 64f7a995b0f3b213e353486c5b6c6132f9bb124d Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Mon, 2 May 2016 21:41:03 +0000 Subject: [PATCH] =?utf8?q?Fix=20llvm-size=20to=20exit=20with=20non=20zero?= =?utf8?q?=20when=20it=20can=E2=80=99t=20open=20a=20file.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit rdar://26027819 llvm-svn: 268313 --- llvm/test/tools/llvm-size/basic.test | 2 +- llvm/tools/llvm-size/llvm-size.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/llvm/test/tools/llvm-size/basic.test b/llvm/test/tools/llvm-size/basic.test index 614c6394..88b8dcb 100644 --- a/llvm/test/tools/llvm-size/basic.test +++ b/llvm/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/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index 1be173b..e3b487c 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/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; } -- 2.7.4