aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaith Rivera <fnrivera@ucsd.edu>2025-08-28 02:23:10 -0700
committerGitHub <noreply@github.com>2025-08-28 10:23:10 +0100
commit7060fc5f8f99bbdf632163cc34b5506a2d565bb6 (patch)
treee79aedc07d55656db1c250cb429ccc1dfd7c0384
parentd8285dfb3390c522f1b597cf8642ce78bded3115 (diff)
downloadllvm-7060fc5f8f99bbdf632163cc34b5506a2d565bb6.zip
llvm-7060fc5f8f99bbdf632163cc34b5506a2d565bb6.tar.gz
llvm-7060fc5f8f99bbdf632163cc34b5506a2d565bb6.tar.bz2
[llvm-lto2] Added version command for llvm-lto2 (#148866)
Previously, the only way to check version for llvm-lto2 was to add version as a subcommand: `llvm-lto2 run --version`. This adds version as a main command for llvm-lto2 for more intuitive access. You can now check version with the command `llvm-lto2 --version`.
-rw-r--r--llvm/test/tools/llvm-lto2/version.test7
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp4
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-lto2/version.test b/llvm/test/tools/llvm-lto2/version.test
new file mode 100644
index 0000000..80e465a
--- /dev/null
+++ b/llvm/test/tools/llvm-lto2/version.test
@@ -0,0 +1,7 @@
+## Show that you can run version as a main command for llvm-lto2
+## or a subcommand of llvm-lto2 run.
+
+RUN: llvm-lto2 --version | FileCheck %s
+RUN: llvm-lto2 run --version | FileCheck %s
+
+CHECK: version
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index fbde666..d27a219 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -616,5 +616,9 @@ int main(int argc, char **argv) {
outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
return 0;
}
+ if (Subcommand == "--version") {
+ cl::PrintVersionMessage();
+ return 0;
+ }
return usage();
}