Skip to content

Commit 8f9e444

Browse files
committed
Switch check_clang_tidy to argparse and add a -resource-dir argument.
-resource-dir can be used to inject non-standard resource dirs via the lit site config. llvm-svn: 251021
1 parent 5884a1f commit 8f9e444

36 files changed

+55
-44
lines changed

clang-tools-extra/test/clang-tidy/cert-setlongjmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s cert-err52-cpp %t -- -std=c++11
1+
// RUN: %check_clang_tidy %s cert-err52-cpp %t -- -- -std=c++11
22

33
typedef void *jmp_buf;
44
extern int __setjmpimpl(jmp_buf);

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
This script runs clang-tidy in fix mode and verify fixes, messages or both.
1717

1818
Usage:
19-
check_clang_tidy.py <source-file> <check-name> <temp-file> \
20-
[optional clang-tidy arguments]
19+
check_clang_tidy.py [-resource-dir <resource-dir>] \
20+
<source-file> <check-name> <temp-file> \
21+
-- [optional clang-tidy arguments]
2122

2223
Example:
2324
// RUN: %check_clang_tidy %s llvm-include-order %t -- -isystem $(dirname %s)/Inputs/Headers
2425
"""
2526

27+
import argparse
2628
import re
2729
import subprocess
2830
import sys
@@ -34,21 +36,30 @@ def write_file(file_name, text):
3436
f.truncate()
3537

3638
def main():
37-
if len(sys.argv) < 4:
38-
sys.exit('Not enough arguments.')
39+
parser = argparse.ArgumentParser()
40+
parser.add_argument('-resource-dir')
41+
parser.add_argument('input_file_name')
42+
parser.add_argument('check_name')
43+
parser.add_argument('temp_file_name')
44+
45+
args, extra_args = parser.parse_known_args()
46+
47+
resource_dir = args.resource_dir
48+
input_file_name = args.input_file_name
49+
check_name = args.check_name
50+
temp_file_name = args.temp_file_name
3951

40-
input_file_name = sys.argv[1]
4152
extension = '.cpp'
4253
if (input_file_name.endswith('.c')):
4354
extension = '.c'
55+
temp_file_name = temp_file_name + extension
4456

45-
check_name = sys.argv[2]
46-
temp_file_name = sys.argv[3] + extension
47-
48-
clang_tidy_extra_args = sys.argv[4:]
57+
clang_tidy_extra_args = extra_args
4958
if len(clang_tidy_extra_args) == 0:
5059
clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
5160
else ['--']
61+
if resource_dir is not None:
62+
clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
5263

5364
with open(input_file_name, 'r') as input_file:
5465
input_text = input_file.read()

clang-tools-extra/test/clang-tidy/google-readability-casting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s google-readability-casting %t -- -x c
1+
// RUN: %check_clang_tidy %s google-readability-casting %t -- -- -x c
22
// The testing script always adds .cpp extension to the input file name, so we
33
// need to run clang-tidy directly in order to verify handling of .c files:
44
// RUN: clang-tidy --checks=-*,google-readability-casting %s -- -x c++ | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'

clang-tools-extra/test/clang-tidy/google-readability-todo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s google-readability-todo %t -config="{User: 'some user'}" --
1+
// RUN: %check_clang_tidy %s google-readability-todo %t -- -config="{User: 'some user'}" --
22

33
// TODOfix this1
44
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO

clang-tools-extra/test/clang-tidy/google-runtime-int-std.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s google-runtime-int %t \
1+
// RUN: %check_clang_tidy %s google-runtime-int %t -- \
22
// RUN: -config='{CheckOptions: [ \
33
// RUN: {key: google-runtime-int.UnsignedTypePrefix, value: "std::uint"}, \
44
// RUN: {key: google-runtime-int.SignedTypePrefix, value: "std::int"}, \

clang-tools-extra/test/clang-tidy/llvm-include-order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s llvm-include-order %t -- -isystem %S/Inputs/Headers
1+
// RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs/Headers
22

33
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
44
#include "j.h"

clang-tools-extra/test/clang-tidy/misc-assert-side-effect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-assert-side-effect %t -config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert'}]}" -- -fexceptions
1+
// RUN: %check_clang_tidy %s misc-assert-side-effect %t -- -config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert'}]}" -- -fexceptions
22

33
//===--- assert definition block ------------------------------------------===//
44
int abort() { return 0; }

clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -std=c++11 -isystem %S/Inputs/Headers
1+
// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
22

33
#include <s.h>
44

clang-tools-extra/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-new-delete-overloads %t -- -std=c++14 -fsized-deallocation
1+
// RUN: %check_clang_tidy %s misc-new-delete-overloads %t -- -- -std=c++14 -fsized-deallocation
22

33
typedef decltype(sizeof(int)) size_t;
44

clang-tools-extra/test/clang-tidy/misc-new-delete-overloads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-new-delete-overloads %t -- -std=c++14
1+
// RUN: %check_clang_tidy %s misc-new-delete-overloads %t -- -- -std=c++14
22

33
typedef decltype(sizeof(int)) size_t;
44

clang-tools-extra/test/clang-tidy/misc-sizeof-container.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-sizeof-container %t -- -std=c++11 -target x86_64-unknown-unknown
1+
// RUN: %check_clang_tidy %s misc-sizeof-container %t -- -- -std=c++11 -target x86_64-unknown-unknown
22

33
namespace std {
44

clang-tools-extra/test/clang-tidy/misc-static-assert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-static-assert %t -- -std=c11
1+
// RUN: %check_clang_tidy %s misc-static-assert %t -- -- -std=c11
22
// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
33

44
void abort() {}

clang-tools-extra/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-throw-by-value-catch-by-reference %t -- -std=c++11 -fcxx-exceptions
1+
// RUN: %check_clang_tidy %s misc-throw-by-value-catch-by-reference %t -- -- -std=c++11 -fcxx-exceptions
22

33

44
class logic_error {

clang-tools-extra/test/clang-tidy/misc-unused-parameters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -xc
1+
// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -xc
22

33
// Basic removal
44
// =============

clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: echo "static void staticFunctionHeader(int i) {}" > %T/header.h
22
// RUN: echo "static void staticFunctionHeader(int /*i*/) {}" > %T/header-fixed.h
3-
// RUN: %check_clang_tidy %s misc-unused-parameters %t -header-filter='.*' -- -std=c++11 -fno-delayed-template-parsing
3+
// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -header-filter='.*' -- -std=c++11 -fno-delayed-template-parsing
44
// RUN: diff %T/header.h %T/header-fixed.h
55

66
#include "header.h"

clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -std=c++11 -I %S/Inputs/modernize-loop-convert
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -std=c++11 -I %S/Inputs/modernize-loop-convert
22

33
#include "structures.h"
44

clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t \
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
22
// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'camelBack'}]}" \
33
// RUN: -- -std=c++11 -I %S/Inputs/modernize-loop-convert
44

clang-tools-extra/test/clang-tidy/modernize-loop-convert-extra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -std=c++11 -I %S/Inputs/modernize-loop-convert
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -std=c++11 -I %S/Inputs/modernize-loop-convert
22

33
#include "structures.h"
44

clang-tools-extra/test/clang-tidy/modernize-loop-convert-lowercase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t \
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
22
// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'lower_case'}]}" \
33
// RUN: -- -std=c++11 -I %S/Inputs/modernize-loop-convert
44

clang-tools-extra/test/clang-tidy/modernize-loop-convert-negative.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -std=c++11 -I %S/Inputs/modernize-loop-convert
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -std=c++11 -I %S/Inputs/modernize-loop-convert
22

33
#include "structures.h"
44

clang-tools-extra/test/clang-tidy/modernize-loop-convert-uppercase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-loop-convert %t \
1+
// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
22
// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'UPPER_CASE'}]}" \
33
// RUN: -- -std=c++11 -I %S/Inputs/modernize-loop-convert
44

clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -std=c++11 -fno-delayed-template-parsing
1+
// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 -fno-delayed-template-parsing
22

33
// CHECK-FIXES: #include <utility>
44

clang-tools-extra/test/clang-tidy/modernize-replace-auto-ptr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-replace-auto-ptr %t -- \
1+
// RUN: %check_clang_tidy %s modernize-replace-auto-ptr %t -- -- \
22
// RUN: -std=c++11 -I %S/Inputs/modernize-replace-auto-ptr
33

44
// CHECK-FIXES: #include <utility>

clang-tools-extra/test/clang-tidy/modernize-use-auto-iterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
1+
// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
22
// RUN: -std=c++11 -I %S/Inputs/modernize-use-auto
33

44
#include "containers.h"

clang-tools-extra/test/clang-tidy/modernize-use-default.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-default %t -- -std=c++11 -fno-delayed-template-parsing
1+
// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing
22

33
class A {
44
public:

clang-tools-extra/test/clang-tidy/modernize-use-nullptr-basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- \
1+
// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- \
22
// RUN: -std=c++98 -Wno-non-literal-null-conversion
33
//
44
// Some parts of the test (e.g. assignment of `const int` to `int *`) fail in

clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-nullptr %t \
1+
// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- \
22
// RUN: -config="{CheckOptions: [{key: modernize-use-nullptr.NullMacros, value: 'MY_NULL,NULL'}]}" \
33
// RUN: -- -std=c++11
44

clang-tools-extra/test/clang-tidy/modernize-use-override-cxx98.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-override %t -- -std=c++98
1+
// RUN: %check_clang_tidy %s modernize-use-override %t -- -- -std=c++98
22

33
struct Base {
44
virtual ~Base() {}

clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" --
1+
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" --
22

33
void do_something(const char *) {}
44

clang-tools-extra/test/clang-tidy/readability-braces-around-statements-same-line.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 1}]}" --
1+
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 1}]}" --
22

33
void do_something(const char *) {}
44

clang-tools-extra/test/clang-tidy/readability-braces-around-statements-single-line.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" --
1+
// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" --
22

33
void do_something(const char *) {}
44

clang-tools-extra/test/clang-tidy/readability-function-size.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-function-size %t -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}]}' -- -std=c++11
1+
// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}]}' -- -std=c++11
22

33
void foo1() {
44
}

clang-tools-extra/test/clang-tidy/readability-identifier-naming.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-identifier-naming %t \
1+
// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
22
// RUN: -config='{CheckOptions: [ \
33
// RUN: {key: readability-identifier-naming.AbstractClassCase, value: CamelCase}, \
44
// RUN: {key: readability-identifier-naming.AbstractClassPrefix, value: 'A'}, \

clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- -std=c++11 -fno-delayed-template-parsing
1+
// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- -- -std=c++11 -fno-delayed-template-parsing
22

33
void consistentFunction(int a, int b, int c);
44
void consistentFunction(int a, int b, int c);

clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr-chained-conditional-assignment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalAssignment", value: 1}]}" --
1+
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -- -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalAssignment", value: 1}]}" --
22

33
void chained_conditional_compound_assignment(int i) {
44
bool b;

clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr-chained-conditional-return.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalReturn", value: 1}]}" --
1+
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -- -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalReturn", value: 1}]}" --
22

33
bool chained_conditional_compound_return(int i) {
44
if (i < 0) {

0 commit comments

Comments
 (0)