[llvm-strings] Remove use of hard coded executable name

Other tools take their tool name from argv[0] for use in output
messages. This change makes llvm-strings consistent with other tools
rather than using a hard coded value.

Differential Revision: https://reviews.llvm.org/D116604
This commit is contained in:
gbreynoo 2022-01-05 14:34:45 +00:00
parent 96f5cc1ee4
commit b30a18f445
4 changed files with 6 additions and 5 deletions

View File

@ -4,7 +4,7 @@ RUN: llvm-strings -h | FileCheck %s
RUN: llvm-strings --help | FileCheck %s
CHECK: OVERVIEW: llvm string dumper
CHECK: USAGE: llvm-strings [options] <input object files>{{$}}
CHECK: USAGE: {{.*}}llvm-strings{{(.exe)?}} [options] <input object files>{{$}}
CHECK: OPTIONS:
CHECK: --all
CHECK: -a

View File

@ -23,7 +23,7 @@ RUN: llvm-strings --bytes 2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-
RUN: llvm-strings --bytes=2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}}
RUN: llvm-strings -n 2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}}
CHECK-0: llvm-strings: error: expected a positive integer, but got '0'
CHECK-0: error: expected a positive integer, but got '0'
CHECK-1: a
CHECK-1-NEXT: ab
@ -43,4 +43,4 @@ CHECK-5: abcde
## Show that a non-numeric argument is rejected.
RUN: not llvm-strings -n foo %t 2>&1 | FileCheck %s --check-prefix=ERR
ERR: llvm-strings: error: expected a positive integer, but got 'foo'
ERR: error: expected a positive integer, but got 'foo'

View File

@ -58,4 +58,4 @@ CHECK-HEX: {{^}} 28 nine
## Show that an invalid value is rejected.
RUN: not llvm-strings --radix z %t/a.txt 2>&1 | FileCheck %s --check-prefix=INVALID
INVALID: llvm-strings: error: --radix value should be one of: '' (no offset), 'o' (octal), 'd' (decimal), 'x' (hexadecimal)
INVALID: error: --radix value should be one of: '' (no offset), 'o' (octal), 'd' (decimal), 'x' (hexadecimal)

View File

@ -61,7 +61,7 @@ public:
};
} // namespace
const char ToolName[] = "llvm-strings";
static StringRef ToolName;
static cl::list<std::string> InputFileNames(cl::Positional,
cl::desc("<input object files>"),
@ -129,6 +129,7 @@ int main(int argc, char **argv) {
BumpPtrAllocator A;
StringSaver Saver(A);
StringsOptTable Tbl;
ToolName = argv[0];
opt::InputArgList Args =
Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver,
[&](StringRef Msg) { reportCmdLineError(Msg); });