Skip to content

Commit daeeb33

Browse files
author
Serge Guelton
committed
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
1 parent db134aa commit daeeb33

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

llvm/tools/llvm-size/llvm-size.cpp

+32-26
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@
3232
using namespace llvm;
3333
using namespace object;
3434

35+
cl::OptionCategory SizeCat("llvm-size Options");
36+
3537
enum OutputFormatTy { berkeley, sysv, darwin };
3638
static cl::opt<OutputFormatTy>
37-
OutputFormat("format", cl::desc("Specify output format"),
38-
cl::values(clEnumVal(sysv, "System V format"),
39-
clEnumVal(berkeley, "Berkeley format"),
40-
clEnumVal(darwin, "Darwin -m format")),
41-
cl::init(berkeley));
42-
43-
static cl::opt<OutputFormatTy> OutputFormatShort(
44-
cl::desc("Specify output format"),
45-
cl::values(clEnumValN(sysv, "A", "System V format"),
46-
clEnumValN(berkeley, "B", "Berkeley format"),
47-
clEnumValN(darwin, "m", "Darwin -m format")),
48-
cl::init(berkeley));
39+
OutputFormat("format", cl::desc("Specify output format"),
40+
cl::values(clEnumVal(sysv, "System V format"),
41+
clEnumVal(berkeley, "Berkeley format"),
42+
clEnumVal(darwin, "Darwin -m format")),
43+
cl::init(berkeley), cl::cat(SizeCat));
44+
45+
static cl::opt<OutputFormatTy>
46+
OutputFormatShort(cl::desc("Specify output format"),
47+
cl::values(clEnumValN(sysv, "A", "System V format"),
48+
clEnumValN(berkeley, "B", "Berkeley format"),
49+
clEnumValN(darwin, "m", "Darwin -m format")),
50+
cl::init(berkeley), cl::cat(SizeCat));
4951

5052
static bool BerkeleyHeaderPrinted = false;
5153
static bool MoreThanOneFile = false;
@@ -55,44 +57,47 @@ static uint64_t TotalObjectBss = 0;
5557
static uint64_t TotalObjectTotal = 0;
5658

5759
cl::opt<bool>
58-
DarwinLongFormat("l", cl::desc("When format is darwin, use long format "
59-
"to include addresses and offsets."));
60+
DarwinLongFormat("l",
61+
cl::desc("When format is darwin, use long format "
62+
"to include addresses and offsets."),
63+
cl::cat(SizeCat));
6064

6165
cl::opt<bool>
6266
ELFCommons("common",
6367
cl::desc("Print common symbols in the ELF file. When using "
6468
"Berkely format, this is added to bss."),
65-
cl::init(false));
69+
cl::init(false), cl::cat(SizeCat));
6670

6771
static cl::list<std::string>
68-
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
69-
cl::ZeroOrMore);
72+
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
73+
cl::ZeroOrMore, cl::cat(SizeCat));
7074
static bool ArchAll = false;
7175

7276
enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 };
7377
static cl::opt<RadixTy> Radix(
7478
"radix", cl::desc("Print size in radix"), cl::init(decimal),
7579
cl::values(clEnumValN(octal, "8", "Print size in octal"),
7680
clEnumValN(decimal, "10", "Print size in decimal"),
77-
clEnumValN(hexadecimal, "16", "Print size in hexadecimal")));
81+
clEnumValN(hexadecimal, "16", "Print size in hexadecimal")),
82+
cl::cat(SizeCat));
7883

79-
static cl::opt<RadixTy>
80-
RadixShort(cl::desc("Print size in radix:"),
81-
cl::values(clEnumValN(octal, "o", "Print size in octal"),
82-
clEnumValN(decimal, "d", "Print size in decimal"),
83-
clEnumValN(hexadecimal, "x", "Print size in hexadecimal")),
84-
cl::init(decimal));
84+
static cl::opt<RadixTy> RadixShort(
85+
cl::desc("Print size in radix:"),
86+
cl::values(clEnumValN(octal, "o", "Print size in octal"),
87+
clEnumValN(decimal, "d", "Print size in decimal"),
88+
clEnumValN(hexadecimal, "x", "Print size in hexadecimal")),
89+
cl::init(decimal), cl::cat(SizeCat));
8590

8691
static cl::opt<bool>
8792
TotalSizes("totals",
8893
cl::desc("Print totals of all objects - Berkeley format only"),
89-
cl::init(false));
94+
cl::init(false), cl::cat(SizeCat));
9095

9196
static cl::alias TotalSizesShort("t", cl::desc("Short for --totals"),
9297
cl::aliasopt(TotalSizes));
9398

9499
static cl::list<std::string>
95-
InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
100+
InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
96101

97102
static bool HadError = false;
98103

@@ -860,6 +865,7 @@ static void printBerkelyTotals() {
860865

861866
int main(int argc, char **argv) {
862867
InitLLVM X(argc, argv);
868+
cl::HideUnrelatedOptions(SizeCat);
863869
cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n");
864870

865871
ToolName = argv[0];

0 commit comments

Comments
 (0)