diff --git a/llvm/test/tools/llvm-readtapi/command-line.test b/llvm/test/tools/llvm-readtapi/command-line.test index 1006bfe9cc2537..59a247c0f593de 100644 --- a/llvm/test/tools/llvm-readtapi/command-line.test +++ b/llvm/test/tools/llvm-readtapi/command-line.test @@ -4,12 +4,17 @@ ; RUN: not llvm-readtapi -merge -compare -compact %t/tmp.tbd %t/tmp2.tbd 2>&1 | FileCheck %s --check-prefix MULTI_ACTION // Check unsupported file output format. ; RUN: not llvm-readtapi -merge -compact %t/tmp.tbd %t/tmp2.tbd --filetype=tbd-v2 2>&1 | FileCheck %s --check-prefix FILE_FORMAT +// Check version printing. +; RUN: llvm-readtapi -v 2>&1 | FileCheck %s --check-prefix VERSION +; RUN: llvm-readtapi --version 2>&1 | FileCheck %s --check-prefix VERSION -CHECK: OVERVIEW: LLVM TAPI file reader and manipulator -CHECK: USAGE: llvm-readtapi [options] [-arch ]* [-o ]* -CHECK: OPTIONS: -CHECK: -help display this help +; CHECK: OVERVIEW: LLVM TAPI file reader and transformer +; CHECK: USAGE: llvm-readtapi [-arch ]* [-o ]* +; CHECK: COMMANDS: +; CHECK: OPTIONS: +; CHECK: -help display this help -MULTI_ACTION: error: only one of the following actions can be specified: -merge -compare -FILE_FORMAT: error: deprecated filetype 'tbd-v2' is not supported to write +; MULTI_ACTION: error: only one of the following actions can be specified: -merge -compare +; FILE_FORMAT: error: deprecated filetype 'tbd-v2' is not supported to write +; VERSION: {{ version }} diff --git a/llvm/tools/llvm-readtapi/TapiOpts.td b/llvm/tools/llvm-readtapi/TapiOpts.td index 8fda035142a2ea..552690ce1385db 100644 --- a/llvm/tools/llvm-readtapi/TapiOpts.td +++ b/llvm/tools/llvm-readtapi/TapiOpts.td @@ -10,17 +10,19 @@ multiclass JS { // // Top level operations // -def action_group : OptionGroup<"action group">; +def action_group : OptionGroup<"action group">, HelpText<"COMMANDS">; def compare : FF<"compare", "compare tapi files for library differences">, Group; def merge : FF<"merge", "merge the input files that represent the same library">, Group; -def extract: FF<"extract", "extract architecture from input file">, Group; -def remove: FF<"remove", "remove architecture from input file">, Group; +def extract: FF<"extract", "extract from input file">, Group; +def remove: FF<"remove", "remove from input file">, Group; // // General Driver options // def help : FF<"help", "display this help">; +def version: FF<"version", "print the llvm-readtapi version">; +def v: FF<"v", "alias for --version">, Alias; defm output: JS<"o", "write output to ","">; def compact: FF<"compact", "write compact tapi output file">; defm filetype: JS<"filetype", "specify the output file type (tbd-v3, tbd-v4 or tbd-v5)","">; -defm arch: JS<"arch", "specify the architecture", "">; +defm arch: JS<"arch", "specify the ", "">; diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp index 64eff70dbfc75d..5fa023d1252582 100644 --- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp +++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp @@ -1,4 +1,4 @@ -//===-- llvm-readtapi.cpp - tapi file reader and manipulator -----*- C++-*-===// +//===-- llvm-readtapi.cpp - tapi file reader and transformer -----*- C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -171,9 +171,15 @@ int main(int Argc, char **Argv) { Argc, Argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) { reportError(Msg); }); if (Args.hasArg(OPT_help)) { Tbl.printHelp(outs(), - "USAGE: llvm-readtapi [options] [-arch ]* [-o " + "USAGE: llvm-readtapi [-arch " + "]* [-o " "]*", - "LLVM TAPI file reader and manipulator"); + "LLVM TAPI file reader and transformer"); + return EXIT_SUCCESS; + } + + if (Args.hasArg(OPT_version)) { + cl::PrintVersionMessage(); return EXIT_SUCCESS; }