summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
diff options
context:
space:
mode:
authorZinovy Nis <zinovy.nis@gmail.com>2019-03-27 19:21:32 +0000
committerZinovy Nis <zinovy.nis@gmail.com>2019-03-27 19:21:32 +0000
commitf8b7269f983aad40730ad845dae5c3d2f43093b0 (patch)
treec52608e5813983a0d2c4640767205395f770ab2a /clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
parent1a0a24f1104af4a4b4df80ab729ff3640a44eb70 (diff)
downloadbcm5719-llvm-f8b7269f983aad40730ad845dae5c3d2f43093b0.tar.gz
bcm5719-llvm-f8b7269f983aad40730ad845dae5c3d2f43093b0.zip
[clang-tidy] Handle missing yaml module in run-clang-tidy.py
The Yaml module is missing on some systems and on many of clang buildbots. But the test for run-clang-tidy.py doesn't fail due to 'NOT' statement masking a python runtime error. This patch conditionally imports and enables the yaml module only if it's present in the system. If not, then '-export-fixes' is disabled. Differential Revision: https://reviews.llvm.org/D59734 llvm-svn: 357114
Diffstat (limited to 'clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py')
-rwxr-xr-xclang-tools-extra/clang-tidy/tool/clang-tidy-diff.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index b9b0fd987a9..8b6ad904557 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -36,11 +36,10 @@ import tempfile
import threading
import traceback
-yaml_imported = True
try:
import yaml
except ImportError:
- yaml_imported = False
+ yaml = None
is_py2 = sys.version[0] == '2'
@@ -144,7 +143,7 @@ def main():
default='')
parser.add_argument('-path', dest='build_path',
help='Path used to read a compile command database.')
- if yaml_imported:
+ if yaml:
parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
help='Create a yaml file to store suggested fixes in, '
'which can be applied with clang-apply-replacements.')
@@ -204,7 +203,7 @@ def main():
max_task_count = min(len(lines_by_file), max_task_count)
tmpdir = None
- if yaml_imported and args.export_fixes:
+ if yaml and args.export_fixes:
tmpdir = tempfile.mkdtemp()
# Tasks for clang-tidy.
@@ -238,7 +237,7 @@ def main():
# Run clang-tidy on files containing changes.
command = [args.clang_tidy_binary]
command.append('-line-filter=' + line_filter_json)
- if yaml_imported and args.export_fixes:
+ if yaml and args.export_fixes:
# Get a temporary file. We immediately close the handle so clang-tidy can
# overwrite it.
(handle, tmp_name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
@@ -253,7 +252,7 @@ def main():
# Wait for all threads to be done.
task_queue.join()
- if yaml_imported and args.export_fixes:
+ if yaml and args.export_fixes:
print('Writing fixes to ' + args.export_fixes + ' ...')
try:
merge_replacement_files(tmpdir, args.export_fixes)
OpenPOWER on IntegriCloud