1
- // ===-- llvm-tapi-diff.cpp - tbd comparator command-line driver ---*-
2
- // C++
3
- // -*-===//
1
+ // ===-- llvm-tapi-diff.cpp - tbd comparator command-line driver --*- C++-*-===//
4
2
//
5
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6
4
// See https://llvm.org/LICENSE.txt for license information.
@@ -31,16 +29,8 @@ cl::opt<std::string> InputFileNameLHS(cl::Positional, cl::desc("<first file>"),
31
29
cl::cat(NMCat));
32
30
cl::opt<std::string> InputFileNameRHS (cl::Positional, cl::desc(" <second file>" ),
33
31
cl::cat(NMCat));
34
-
35
- std::string ToolName;
36
32
} // anonymous namespace
37
33
38
- ExitOnError ExitOnErr;
39
-
40
- void setErrorBanner (ExitOnError &ExitOnErr, std::string InputFile) {
41
- ExitOnErr.setBanner (ToolName + " : error: " + InputFile + " : " );
42
- }
43
-
44
34
Expected<std::unique_ptr<Binary>> convertFileToBinary (std::string &Filename) {
45
35
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
46
36
MemoryBuffer::getFileOrSTDIN (Filename);
@@ -52,35 +42,29 @@ Expected<std::unique_ptr<Binary>> convertFileToBinary(std::string &Filename) {
52
42
int main (int Argc, char **Argv) {
53
43
InitLLVM X (Argc, Argv);
54
44
cl::HideUnrelatedOptions (NMCat);
55
- cl::ParseCommandLineOptions (
56
- Argc, Argv,
57
- " This tool will compare two tbd files and return the "
58
- " differences in those files." );
45
+ cl::ParseCommandLineOptions (Argc, Argv, " Text-based Stubs Comparison Tool" );
59
46
if (InputFileNameLHS.empty () || InputFileNameRHS.empty ()) {
60
47
cl::PrintHelpMessage ();
61
48
return EXIT_FAILURE;
62
49
}
63
50
64
- ToolName = Argv[0 ];
65
-
66
- setErrorBanner (ExitOnErr, InputFileNameLHS);
51
+ ExitOnError ExitOnErr (" error: '" + InputFileNameLHS + " ' " ,
52
+ /* DefaultErrorExitCode=*/ 2 );
67
53
auto BinLHS = ExitOnErr (convertFileToBinary (InputFileNameLHS));
68
54
69
55
TapiUniversal *FileLHS = dyn_cast<TapiUniversal>(BinLHS.get ());
70
56
if (!FileLHS) {
71
- ExitOnErr (
72
- createStringError (std::errc::executable_format_error,
73
- " Error when parsing file, unsupported file format" ));
57
+ ExitOnErr (createStringError (std::errc::executable_format_error,
58
+ " unsupported file format" ));
74
59
}
75
60
76
- setErrorBanner ( ExitOnErr, InputFileNameRHS);
61
+ ExitOnErr. setBanner ( " error: ' " + InputFileNameRHS + " ' " );
77
62
auto BinRHS = ExitOnErr (convertFileToBinary (InputFileNameRHS));
78
63
79
64
TapiUniversal *FileRHS = dyn_cast<TapiUniversal>(BinRHS.get ());
80
65
if (!FileRHS) {
81
- ExitOnErr (
82
- createStringError (std::errc::executable_format_error,
83
- " Error when parsing file, unsupported file format" ));
66
+ ExitOnErr (createStringError (std::errc::executable_format_error,
67
+ " unsupported file format" ));
84
68
}
85
69
86
70
raw_ostream &OS = outs ();
0 commit comments