[PATCH] D115905: [llvm-tapi-diff] Replicate diff utility error handling
Cyndy Ishida via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 18 10:13:57 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG982604cc08ca: [llvm-tapi-diff] Replicate diff utility error handling (authored by cishida).
Changed prior to commit:
https://reviews.llvm.org/D115905?vs=394989&id=395300#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115905/new/
https://reviews.llvm.org/D115905
Files:
llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test
llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test
llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp
Index: llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp
===================================================================
--- llvm/tools/llvm-tapi-diff/llvm-tapi-diff.cpp
+++ 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<std::string> InputFileNameRHS(cl::Positional, cl::desc("<second file>"),
cl::cat(NMCat));
-
-std::string ToolName;
} // anonymous namespace
-ExitOnError ExitOnErr;
-
-void setErrorBanner(ExitOnError &ExitOnErr, std::string InputFile) {
- ExitOnErr.setBanner(ToolName + ": error: " + InputFile + ": ");
-}
-
Expected<std::unique_ptr<Binary>> convertFileToBinary(std::string &Filename) {
ErrorOr<std::unique_ptr<MemoryBuffer>> 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<TapiUniversal>(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<TapiUniversal>(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();
Index: llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test
===================================================================
--- llvm/test/tools/llvm-tapi-diff/tapi-diff-misspelled-tbd.test
+++ 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
Index: llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test
===================================================================
--- llvm/test/tools/llvm-tapi-diff/tapi-diff-incorrect-format.test
+++ 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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115905.395300.patch
Type: text/x-patch
Size: 4127 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211218/d0ebe288/attachment.bin>
More information about the llvm-commits
mailing list