[PATCH] D37138: Make run-clang-tidy compatible with Python 3.x

Kevin Funk via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 05:37:55 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312532: Make run-clang-tidy compatible with Python 3.x (authored by kfunk).

Changed prior to commit:
  https://reviews.llvm.org/D37138?vs=112677&id=113841#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37138

Files:
  clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -35,12 +35,12 @@
 """
 
 from __future__ import print_function
+
 import argparse
 import glob
 import json
 import multiprocessing
 import os
-import Queue
 import re
 import shutil
 import subprocess
@@ -50,6 +50,12 @@
 import traceback
 import yaml
 
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+    import Queue as queue
+else:
+    import queue as queue
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
@@ -233,20 +239,20 @@
 
   try:
     # Spin up a bunch of tidy-launching threads.
-    queue = Queue.Queue(max_task)
+    task_queue = queue.Queue(max_task)
     for _ in range(max_task):
       t = threading.Thread(target=run_tidy,
-                           args=(args, tmpdir, build_path, queue))
+                           args=(args, tmpdir, build_path, task_queue))
       t.daemon = True
       t.start()
 
     # Fill the queue with files.
     for name in files:
       if file_name_re.search(name):
-        queue.put(name)
+        task_queue.put(name)
 
     # Wait for all threads to be done.
-    queue.join()
+    task_queue.join()
 
   except KeyboardInterrupt:
     # This is a sad hack. Unfortunately subprocess goes


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37138.113841.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170905/d798344c/attachment.bin>


More information about the cfe-commits mailing list