[PATCH] D34567: [opt-viewer] Remove positional arg checks (NFC)

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 12:53:08 PDT 2017


modocache created this revision.
Herald added a subscriber: fhahn.

opt-stats.py and opt-viewer.py's argument parsers both take a positional
argument 'yaml_files'. Positional arguments in Python's argparse module are
required by default, so the subsequent checks for `len(args.yaml_files) == 0`
are unnecessary -- if the length was zero, then the call to
`parser.parse_args()` would have thrown an error already.

Because there is no way for `len(args.yaml_files)` to be zero at these
points, removing the code is NFC.


https://reviews.llvm.org/D34567

Files:
  utils/opt-viewer/opt-stats.py
  utils/opt-viewer/opt-viewer.py


Index: utils/opt-viewer/opt-viewer.py
===================================================================
--- utils/opt-viewer/opt-viewer.py
+++ utils/opt-viewer/opt-viewer.py
@@ -216,10 +216,6 @@
         help='set source directory')
     args = parser.parse_args()
 
-    if len(args.yaml_files) == 0:
-        parser.print_help()
-        sys.exit(1)
-
     if args.jobs == 1:
         pmap = map
     else:
Index: utils/opt-viewer/opt-stats.py
===================================================================
--- utils/opt-viewer/opt-stats.py
+++ utils/opt-viewer/opt-stats.py
@@ -24,10 +24,6 @@
         help='Max job count (defaults to %(default)s, the current CPU count)')
     args = parser.parse_args()
 
-    if len(args.yaml_files) == 0:
-        parser.print_help()
-        sys.exit(1)
-
     if args.jobs == 1:
         pmap = map
     else:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34567.103760.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170623/c1f15f1f/attachment.bin>


More information about the llvm-commits mailing list