diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2019-05-09 17:08:10 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2019-05-09 17:08:10 +0000 |
commit | 4bf8632c45f965ce51f324eec6ab8ede52285581 (patch) | |
tree | f8a2d46922cafa1b8b48951959030ce46f9c4dcb /clang-tools-extra/test/clang-tidy/check_clang_tidy.py | |
parent | be10bc71f9af497cfe93e316e23fab6633ae54f6 (diff) | |
download | bcm5719-llvm-4bf8632c45f965ce51f324eec6ab8ede52285581.tar.gz bcm5719-llvm-4bf8632c45f965ce51f324eec6ab8ede52285581.zip |
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
llvm-svn: 360358
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/check_clang_tidy.py')
-rwxr-xr-x | clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index 5d808f409c2..ceacf0a69d2 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -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) + '...') |