[PATCH] D53799: [llvm-size] Reject unknown radix values
Eugene Sharygin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 29 08:39:47 PDT 2018
eush updated this revision to Diff 171510.
eush added a comment.
Added a test.
Repository:
rL LLVM
https://reviews.llvm.org/D53799
Files:
test/tools/llvm-size/unknown-radix.test
tools/llvm-size/llvm-size.cpp
Index: tools/llvm-size/llvm-size.cpp
===================================================================
--- tools/llvm-size/llvm-size.cpp
+++ tools/llvm-size/llvm-size.cpp
@@ -71,9 +71,11 @@
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:"),
@@ -865,7 +867,7 @@
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") {
Index: test/tools/llvm-size/unknown-radix.test
===================================================================
--- /dev/null
+++ test/tools/llvm-size/unknown-radix.test
@@ -0,0 +1,5 @@
+RUN: not llvm-size -radix=foo 2>&1 | FileCheck --check-prefix=CHECK-NOT-NUMERIC %s
+CHECK-NOT-NUMERIC: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: for the -radix option: Cannot find option named 'foo'!
+
+RUN: not llvm-size -radix=4 2>&1 | FileCheck --check-prefix=CHECK-NUMERIC %s
+CHECK-NUMERIC: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: for the -radix option: Cannot find option named '4'!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53799.171510.patch
Type: text/x-patch
Size: 1691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181029/382240fb/attachment.bin>
More information about the llvm-commits
mailing list