Skip to content

Commit b3735ee

Browse files
committed
[llvm-size] Reject unknown radix values
This addresses https://bugs.llvm.org/show_bug.cgi?id=39403 by making -radix an enumeration option with 8, 10, and 16 as the only accepted values. Reviewed by: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D53799 Patch by Eugene Sharygin llvm-svn: 345588
1 parent 1cc49d3 commit b3735ee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
7171
static bool ArchAll = false;
7272

7373
enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 };
74-
static cl::opt<unsigned int>
75-
Radix("radix", cl::desc("Print size in radix. Only 8, 10, and 16 are valid"),
76-
cl::init(decimal));
74+
static cl::opt<RadixTy> Radix(
75+
"radix", cl::desc("Print size in radix"), cl::init(decimal),
76+
cl::values(clEnumValN(octal, "8", "Print size in octal"),
77+
clEnumValN(decimal, "10", "Print size in decimal"),
78+
clEnumValN(hexadecimal, "16", "Print size in hexadecimal")));
7779

7880
static cl::opt<RadixTy>
7981
RadixShort(cl::desc("Print size in radix:"),
@@ -865,7 +867,7 @@ int main(int argc, char **argv) {
865867
if (OutputFormatShort.getNumOccurrences())
866868
OutputFormat = static_cast<OutputFormatTy>(OutputFormatShort);
867869
if (RadixShort.getNumOccurrences())
868-
Radix = RadixShort;
870+
Radix = RadixShort.getValue();
869871

870872
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
871873
if (ArchFlags[i] == "all") {

0 commit comments

Comments
 (0)