[LNT] r285328 - Avoid running regex on None
Mandeep Singh Grang via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 27 11:30:18 PDT 2016
Author: mgrang
Date: Thu Oct 27 13:30:17 2016
New Revision: 285328
URL: http://llvm.org/viewvc/llvm-project?rev=285328&view=rev
Log:
Avoid running regex on None
Summary:
We are attempting to run regex on version_ln even if it is None. This can cause TypeError.
Patch by Azharuddin Mohammed
Reviewers: cmatthews, mgrang
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25967
Modified:
lnt/trunk/lnt/testing/util/compilers.py
Modified: lnt/trunk/lnt/testing/util/compilers.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/util/compilers.py?rev=285328&r1=285327&r2=285328&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/util/compilers.py (original)
+++ lnt/trunk/lnt/testing/util/compilers.py Thu Oct 27 13:30:17 2016
@@ -77,25 +77,25 @@ def get_cc_info(path, cc_flags=[]):
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.
More information about the llvm-commits
mailing list