[PATCH] D25967: Avoid running regex on None
Azharuddin Mohammed via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 14:29:49 PDT 2016
azharudd created this revision.
azharudd added a reviewer: cmatthews.
azharudd added a subscriber: llvm-commits.
azharudd set the repository for this revision to rL LLVM.
We are attempting to run regex on version_ln even if it is None. This can cause TypeError.
Patch by Azharuddin Mohammed
Repository:
rL LLVM
https://reviews.llvm.org/D25967
Files:
lnt/testing/util/compilers.py
Index: lnt/testing/util/compilers.py
===================================================================
--- lnt/testing/util/compilers.py
+++ lnt/testing/util/compilers.py
@@ -77,25 +77,25 @@
if not m:
fatal("unable to determine cc1 binary: %r: %r" % (cc, ln))
cc1_binary, = m.groups()
+ if cc1_binary is None:
+ error("unable to find compiler cc1 binary: %r: %r" % (cc, cc_version))
if version_ln is None:
error("unable to find compiler version: %r: %r" % (cc, cc_version))
- if cc1_binary is None:
- error("unable to find compiler cc1 binary: %r: %r" % (
- cc, cc_version))
- m = re.match(r'(.*) version ([^ ]*) +(\([^(]*\))(.*)', version_ln)
- if m is not None:
- cc_name,cc_version_num,cc_build_string,cc_extra = m.groups()
else:
- # If that didn't match, try a more basic pattern.
- m = re.match(r'(.*) version ([^ ]*)', version_ln)
+ m = re.match(r'(.*) version ([^ ]*) +(\([^(]*\))(.*)', version_ln)
if m is not None:
- cc_name,cc_version_num = m.groups()
- cc_build_string = cc_extra = ""
+ cc_name,cc_version_num,cc_build_string,cc_extra = m.groups()
else:
- error("unable to determine compiler version: %r: %r" % (
- cc, version_ln))
- cc_name = "unknown"
- cc_version_num = cc_build_string = cc_extra = ""
+ # If that didn't match, try a more basic pattern.
+ m = re.match(r'(.*) version ([^ ]*)', version_ln)
+ if m is not None:
+ cc_name,cc_version_num = m.groups()
+ cc_build_string = cc_extra = ""
+ else:
+ error("unable to determine compiler version: %r: %r" % (
+ cc, version_ln))
+ cc_name = "unknown"
+ cc_version_num = cc_build_string = cc_extra = ""
# Compute normalized compiler name and type. We try to grab source
# revisions, branches, and tags when possible.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25967.75792.patch
Type: text/x-patch
Size: 2075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161025/04f33fc6/attachment.bin>
More information about the llvm-commits
mailing list