[PATCH] D25967: Avoid running regex on None

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 11:39:49 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL285328: Avoid running regex on None (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D25967?vs=75792&id=76075#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25967

Files:
  lnt/trunk/lnt/testing/util/compilers.py


Index: lnt/trunk/lnt/testing/util/compilers.py
===================================================================
--- lnt/trunk/lnt/testing/util/compilers.py
+++ lnt/trunk/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.76075.patch
Type: text/x-patch
Size: 2105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161027/69b9aed4/attachment.bin>


More information about the llvm-commits mailing list