[llvm] b30a18f - [llvm-strings] Remove use of hard coded executable name
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 5 06:42:38 PST 2022
Author: gbreynoo
Date: 2022-01-05T14:41:49Z
New Revision: b30a18f445ea53bd64f92c6305a90162414589b8
URL: https://github.com/llvm/llvm-project/commit/b30a18f445ea53bd64f92c6305a90162414589b8
DIFF: https://github.com/llvm/llvm-project/commit/b30a18f445ea53bd64f92c6305a90162414589b8.diff
LOG: [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
Added:
Modified:
llvm/test/tools/llvm-strings/help.test
llvm/test/tools/llvm-strings/length.test
llvm/test/tools/llvm-strings/radix.test
llvm/tools/llvm-strings/llvm-strings.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-strings/help.test b/llvm/test/tools/llvm-strings/help.test
index 5872dc9753204..5ca6167fa2927 100644
--- a/llvm/test/tools/llvm-strings/help.test
+++ b/llvm/test/tools/llvm-strings/help.test
@@ -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
diff --git a/llvm/test/tools/llvm-strings/length.test b/llvm/test/tools/llvm-strings/length.test
index 4897931f38fe3..896917d8db90d 100644
--- a/llvm/test/tools/llvm-strings/length.test
+++ b/llvm/test/tools/llvm-strings/length.test
@@ -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'
diff --git a/llvm/test/tools/llvm-strings/radix.test b/llvm/test/tools/llvm-strings/radix.test
index e3ef4ce3a0cd8..e13e201b2cf5e 100644
--- a/llvm/test/tools/llvm-strings/radix.test
+++ b/llvm/test/tools/llvm-strings/radix.test
@@ -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)
diff --git a/llvm/tools/llvm-strings/llvm-strings.cpp b/llvm/tools/llvm-strings/llvm-strings.cpp
index 26be3914fb923..438eed33d283b 100644
--- a/llvm/tools/llvm-strings/llvm-strings.cpp
+++ b/llvm/tools/llvm-strings/llvm-strings.cpp
@@ -61,7 +61,7 @@ class StringsOptTable : public opt::OptTable {
};
} // 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); });
More information about the llvm-commits
mailing list