summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2017-10-18 07:48:40 +0000
committerHaojian Wu <hokein@google.com>2017-10-18 07:48:40 +0000
commita08422e0e40d41670471ee7701b6ce9ab0051265 (patch)
treed91751e0cec0238f26bdb7288c307da696ddd79d /clang-tools-extra/test/clang-tidy/check_clang_tidy.py
parent06ea0ce1c9bda6e6935ecc924b94a2822a1bb344 (diff)
downloadbcm5719-llvm-a08422e0e40d41670471ee7701b6ce9ab0051265.tar.gz
bcm5719-llvm-a08422e0e40d41670471ee7701b6ce9ab0051265.zip
New -assume-filename=param to check_clang_tidy.py (like clang-format)
Summary: Currently, check_clang_tidy.py includes logic to select default clang flags based on the extension of the source filename passed as the first argument. Since the source filename might be a temporary or test file with an arbitrary extension unrelated to the file type, this adds the ability to override the logic the same way `clang-format`'s -assume-filename= parameter does. I included a test with a nonstandard file extension. I confirmed when I modified the warning message that the new test failed, and that it passed again when I restored the warning message. Ran tests with: % cmake -G Ninja /path/to/llvm % ninja check-clang-tools Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: alexfh Differential Revision: https://reviews.llvm.org/D38963 llvm-svn: 316066
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/check_clang_tidy.py')
-rwxr-xr-xclang-tools-extra/test/clang-tidy/check_clang_tidy.py9
1 files changed, 7 insertions, 2 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 114f0d55946..986b70be5e4 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -17,6 +17,7 @@ This script runs clang-tidy in fix mode and verify fixes, messages or both.
Usage:
check_clang_tidy.py [-resource-dir <resource-dir>] \
+ [-assume-filename <file-with-source-extension>] \
<source-file> <check-name> <temp-file> \
-- [optional clang-tidy arguments]
@@ -38,6 +39,7 @@ def write_file(file_name, text):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-resource-dir')
+ parser.add_argument('-assume-filename')
parser.add_argument('input_file_name')
parser.add_argument('check_name')
parser.add_argument('temp_file_name')
@@ -45,14 +47,17 @@ def main():
args, extra_args = parser.parse_known_args()
resource_dir = args.resource_dir
+ assume_file_name = args.assume_filename
input_file_name = args.input_file_name
check_name = args.check_name
temp_file_name = args.temp_file_name
+ file_name_with_extension = assume_file_name or input_file_name
+
extension = '.cpp'
- if (input_file_name.endswith('.c')):
+ if (file_name_with_extension.endswith('.c')):
extension = '.c'
- if (input_file_name.endswith('.hpp')):
+ if (file_name_with_extension.endswith('.hpp')):
extension = '.hpp'
temp_file_name = temp_file_name + extension
OpenPOWER on IntegriCloud