Sanitize llvm-size help

Remove irrelevant options from standard help output.

New output:

    OVERVIEW: llvm object size dumper

    USAGE: llvm-size [options] <input files>

    OPTIONS:

    Generic Options:

      --help           - Display available options (--help-hidden for more)
      --help-list      - Display list of available options (--help-list-hidden for more)
      --version        - Display the version of this program

    llvm-size Options:

      Specify output format
          -A             - System V format
          -B             - Berkeley format
          -m             - Darwin -m format
      --arch=<string>  - architecture(s) from a Mach-O file to dump
      --common         - Print common symbols in the ELF file.  When using Berkely format, this is added to bss.
      Print size in radix:
          -o             - Print size in octal
          -d             - Print size in decimal
          -x             - Print size in hexadecimal
      --format=<value> - Specify output format
        =sysv          -   System V format
        =berkeley      -   Berkeley format
        =darwin        -   Darwin -m format
      -l               - When format is darwin, use long format to include addresses and offsets.
      --radix=<value>  - Print size in radix
        =8             -   Print size in octal
        =10            -   Print size in decimal
        =16            -   Print size in hexadecimal
      --totals         - Print totals of all objects - Berkeley format only

Differential Revision: https://reviews.llvm.org/D62482

llvm-svn: 362593
This commit is contained in:
Serge Guelton 2019-06-05 10:32:28 +00:00
parent db134aaec2
commit daeeb33f86
1 changed files with 31 additions and 25 deletions

View File

@ -32,20 +32,22 @@
using namespace llvm; using namespace llvm;
using namespace object; using namespace object;
cl::OptionCategory SizeCat("llvm-size Options");
enum OutputFormatTy { berkeley, sysv, darwin }; enum OutputFormatTy { berkeley, sysv, darwin };
static cl::opt<OutputFormatTy> static cl::opt<OutputFormatTy>
OutputFormat("format", cl::desc("Specify output format"), OutputFormat("format", cl::desc("Specify output format"),
cl::values(clEnumVal(sysv, "System V format"), cl::values(clEnumVal(sysv, "System V format"),
clEnumVal(berkeley, "Berkeley format"), clEnumVal(berkeley, "Berkeley format"),
clEnumVal(darwin, "Darwin -m format")), clEnumVal(darwin, "Darwin -m format")),
cl::init(berkeley)); cl::init(berkeley), cl::cat(SizeCat));
static cl::opt<OutputFormatTy> OutputFormatShort( static cl::opt<OutputFormatTy>
cl::desc("Specify output format"), OutputFormatShort(cl::desc("Specify output format"),
cl::values(clEnumValN(sysv, "A", "System V format"), cl::values(clEnumValN(sysv, "A", "System V format"),
clEnumValN(berkeley, "B", "Berkeley format"), clEnumValN(berkeley, "B", "Berkeley format"),
clEnumValN(darwin, "m", "Darwin -m format")), clEnumValN(darwin, "m", "Darwin -m format")),
cl::init(berkeley)); cl::init(berkeley), cl::cat(SizeCat));
static bool BerkeleyHeaderPrinted = false; static bool BerkeleyHeaderPrinted = false;
static bool MoreThanOneFile = false; static bool MoreThanOneFile = false;
@ -55,18 +57,20 @@ static uint64_t TotalObjectBss = 0;
static uint64_t TotalObjectTotal = 0; static uint64_t TotalObjectTotal = 0;
cl::opt<bool> cl::opt<bool>
DarwinLongFormat("l", cl::desc("When format is darwin, use long format " DarwinLongFormat("l",
"to include addresses and offsets.")); cl::desc("When format is darwin, use long format "
"to include addresses and offsets."),
cl::cat(SizeCat));
cl::opt<bool> cl::opt<bool>
ELFCommons("common", ELFCommons("common",
cl::desc("Print common symbols in the ELF file. When using " cl::desc("Print common symbols in the ELF file. When using "
"Berkely format, this is added to bss."), "Berkely format, this is added to bss."),
cl::init(false)); cl::init(false), cl::cat(SizeCat));
static cl::list<std::string> static cl::list<std::string>
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(SizeCat));
static bool ArchAll = false; static bool ArchAll = false;
enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 }; enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 };
@ -74,25 +78,26 @@ static cl::opt<RadixTy> Radix(
"radix", cl::desc("Print size in radix"), cl::init(decimal), "radix", cl::desc("Print size in radix"), cl::init(decimal),
cl::values(clEnumValN(octal, "8", "Print size in octal"), cl::values(clEnumValN(octal, "8", "Print size in octal"),
clEnumValN(decimal, "10", "Print size in decimal"), clEnumValN(decimal, "10", "Print size in decimal"),
clEnumValN(hexadecimal, "16", "Print size in hexadecimal"))); clEnumValN(hexadecimal, "16", "Print size in hexadecimal")),
cl::cat(SizeCat));
static cl::opt<RadixTy> static cl::opt<RadixTy> RadixShort(
RadixShort(cl::desc("Print size in radix:"), cl::desc("Print size in radix:"),
cl::values(clEnumValN(octal, "o", "Print size in octal"), cl::values(clEnumValN(octal, "o", "Print size in octal"),
clEnumValN(decimal, "d", "Print size in decimal"), clEnumValN(decimal, "d", "Print size in decimal"),
clEnumValN(hexadecimal, "x", "Print size in hexadecimal")), clEnumValN(hexadecimal, "x", "Print size in hexadecimal")),
cl::init(decimal)); cl::init(decimal), cl::cat(SizeCat));
static cl::opt<bool> static cl::opt<bool>
TotalSizes("totals", TotalSizes("totals",
cl::desc("Print totals of all objects - Berkeley format only"), cl::desc("Print totals of all objects - Berkeley format only"),
cl::init(false)); cl::init(false), cl::cat(SizeCat));
static cl::alias TotalSizesShort("t", cl::desc("Short for --totals"), static cl::alias TotalSizesShort("t", cl::desc("Short for --totals"),
cl::aliasopt(TotalSizes)); cl::aliasopt(TotalSizes));
static cl::list<std::string> static cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore); InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
static bool HadError = false; static bool HadError = false;
@ -860,6 +865,7 @@ static void printBerkelyTotals() {
int main(int argc, char **argv) { int main(int argc, char **argv) {
InitLLVM X(argc, argv); InitLLVM X(argc, argv);
cl::HideUnrelatedOptions(SizeCat);
cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n"); cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n");
ToolName = argv[0]; ToolName = argv[0];