[clang-tools-extra] r360358 - check_clang_tidy.py now passes `-format-style=none` to clang_tidy
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Thu May 9 10:08:10 PDT 2019
Author: gribozavr
Date: Thu May 9 10:08:10 2019
New Revision: 360358
URL: http://llvm.org/viewvc/llvm-project?rev=360358&view=rev
Log:
check_clang_tidy.py now passes `-format-style=none` to clang_tidy
Summary:
If the test does not specify a formatting style, force "none"; otherwise
autodetection logic can discover a ".clang-tidy" file that is not
related to the test.
Reviewers: alexfh
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D61739
Modified:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=360358&r1=360357&r2=360358&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Thu May 9 10:08:10 2019
@@ -69,20 +69,32 @@ def main():
temp_file_name = temp_file_name + extension
clang_tidy_extra_args = extra_args
- if len(clang_tidy_extra_args) == 0:
- clang_tidy_extra_args = ['--']
+ clang_extra_args = []
+ if '--' in extra_args:
+ i = clang_tidy_extra_args.index('--')
+ clang_extra_args = clang_tidy_extra_args[i + 1:]
+ clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+ # If the test does not specify a formatting style, force "none"; otherwise
+ # autodetection logic can discover a ".clang-tidy" file that is not related to
+ # the test.
+ if not any(
+ [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+ clang_tidy_extra_args.append('-format-style=none')
+
+ if len(clang_extra_args) == 0:
if extension in ['.cpp', '.hpp', '.mm']:
- clang_tidy_extra_args.append('--std=c++11')
+ clang_extra_args.append('--std=c++11')
if extension in ['.m', '.mm']:
- clang_tidy_extra_args.extend(
+ clang_extra_args.extend(
['-fobjc-abi-version=2', '-fobjc-arc'])
# Tests should not rely on STL being available, and instead provide mock
# implementations of relevant APIs.
- clang_tidy_extra_args.append('-nostdinc++')
+ clang_extra_args.append('-nostdinc++')
if resource_dir is not None:
- clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+ clang_extra_args.append('-resource-dir=%s' % resource_dir)
with open(input_file_name, 'r') as input_file:
input_text = input_file.read()
@@ -138,7 +150,7 @@ def main():
write_file(original_file_name, cleaned_test)
args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \
- clang_tidy_extra_args
+ clang_tidy_extra_args + ['--'] + clang_extra_args
if expect_clang_tidy_error:
args.insert(0, 'not')
print('Running ' + repr(args) + '...')
More information about the cfe-commits
mailing list