Skip to content

Commit

Permalink
[llvm-size] Reject unknown radix values
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jh7370 committed Oct 30, 2018
1 parent 1cc49d3 commit b3735ee
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions llvm/tools/llvm-size/llvm-size.cpp
Expand Up @@ -71,9 +71,11 @@ ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
static bool ArchAll = false;

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

static cl::opt<RadixTy>
RadixShort(cl::desc("Print size in radix:"),
Expand Down Expand Up @@ -865,7 +867,7 @@ int main(int argc, char **argv) {
if (OutputFormatShort.getNumOccurrences())
OutputFormat = static_cast<OutputFormatTy>(OutputFormatShort);
if (RadixShort.getNumOccurrences())
Radix = RadixShort;
Radix = RadixShort.getValue();

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

0 comments on commit b3735ee

Please sign in to comment.