diff --git a/llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test b/llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test --- a/llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test +++ b/llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test @@ -2,6 +2,6 @@ ; RUN: yaml2obj %S/Inputs/macho.yaml -o %t/macho.dylib ; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %t/macho.dylib 2>&1 | FileCheck %s -; CHECK: {{.*}}: error: {{.*}}macho.dylib: Error when parsing file, unsupported file format +; CHECK: error: {{.*}}macho.dylib' unsupported file format ; CHECK-NOT: error: ; CHECK-NOT: warning: diff --git a/llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test b/llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test --- a/llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test +++ b/llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test @@ -1,5 +1,3 @@ -; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck %s -DMSG=%errc_ENOENT +; RUN: not llvm-tapi-diff %S/Inputs/v4A.tbd %S/Inputs/v4.tbd 2>&1 | FileCheck %s -; CHECK: {{.*}}: error: {{.*}}v4.tbd: [[MSG]] -; CHECK-NOT: error: -; CHECK-NOT: warning: +; CHECK: error: {{.*}}v4.tbd' {{[Nn]}}o such file or directory diff --git a/llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp b/llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp --- a/llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp +++ b/llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp @@ -1,6 +1,4 @@ -//===-- llvm-tapi-diff.cpp - tbd comparator command-line driver ---*- -// C++ -//-*-===// +//===-- llvm-tapi-diff.cpp - tbd comparator command-line driver --*- C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -31,16 +29,8 @@ cl::cat(NMCat)); cl::opt InputFileNameRHS(cl::Positional, cl::desc(""), cl::cat(NMCat)); - -std::string ToolName; } // anonymous namespace -ExitOnError ExitOnErr; - -void setErrorBanner(ExitOnError &ExitOnErr, std::string InputFile) { - ExitOnErr.setBanner(ToolName + ": error: " + InputFile + ": "); -} - Expected> convertFileToBinary(std::string &Filename) { ErrorOr> BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename); @@ -52,35 +42,29 @@ int main(int Argc, char **Argv) { InitLLVM X(Argc, Argv); cl::HideUnrelatedOptions(NMCat); - cl::ParseCommandLineOptions( - Argc, Argv, - "This tool will compare two tbd files and return the " - "differences in those files."); + cl::ParseCommandLineOptions(Argc, Argv, "Text-based Stubs Comparison Tool"); if (InputFileNameLHS.empty() || InputFileNameRHS.empty()) { cl::PrintHelpMessage(); return EXIT_FAILURE; } - ToolName = Argv[0]; - - setErrorBanner(ExitOnErr, InputFileNameLHS); + ExitOnError ExitOnErr("error: '" + InputFileNameLHS + "' ", + /*DefaultErrorExitCode=*/2); auto BinLHS = ExitOnErr(convertFileToBinary(InputFileNameLHS)); TapiUniversal *FileLHS = dyn_cast(BinLHS.get()); if (!FileLHS) { - ExitOnErr( - createStringError(std::errc::executable_format_error, - "Error when parsing file, unsupported file format")); + ExitOnErr(createStringError(std::errc::executable_format_error, + "unsupported file format")); } - setErrorBanner(ExitOnErr, InputFileNameRHS); + ExitOnErr.setBanner("error: '" + InputFileNameRHS + "' "); auto BinRHS = ExitOnErr(convertFileToBinary(InputFileNameRHS)); TapiUniversal *FileRHS = dyn_cast(BinRHS.get()); if (!FileRHS) { - ExitOnErr( - createStringError(std::errc::executable_format_error, - "Error when parsing file, unsupported file format")); + ExitOnErr(createStringError(std::errc::executable_format_error, + "unsupported file format")); } raw_ostream &OS = outs();