[clang-tools-extra] r312532 - Make run-clang-tidy compatible with Python 3.x

Kevin Funk via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 05:36:33 PDT 2017


Author: kfunk
Date: Tue Sep  5 05:36:33 2017
New Revision: 312532

URL: http://llvm.org/viewvc/llvm-project?rev=312532&view=rev
Log:
Make run-clang-tidy compatible with Python 3.x

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D37138

Change-Id: I89a95d1e082e566e7e64c2a5ca4123c543e6b1be

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

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=312532&r1=312531&r2=312532&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Tue Sep  5 05:36:33 2017
@@ -35,12 +35,12 @@ http://clang.llvm.org/docs/HowToSetupToo
 """
 
 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 threading
 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 @@ def main():
 
   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




More information about the cfe-commits mailing list