From 106c8e0898688fbdff96b017828da9762f1d6b20 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Sun, 26 Oct 2014 02:58:07 +0000 Subject: [PATCH] [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh Summary: Make the script suitable for checking just messages. Move most of the tests to use it. Clean up the tests: shorten messages, insert line numbers, remove unnecessary RUN: lines, etc. Reviewers: klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5989 llvm-svn: 220634 --- clang-tools-extra/test/clang-tidy/arg-comments.cpp | 13 ++--- .../test/clang-tidy/check_clang_tidy.sh | 45 ++++++++++++++++++ .../test/clang-tidy/check_clang_tidy_fix.sh | 38 --------------- .../test/clang-tidy/google-explicit-make-pair.cpp | 2 +- .../clang-tidy/google-member-string-references.cpp | 9 ++-- .../test/clang-tidy/google-memset-zero-length.cpp | 2 +- .../clang-tidy/google-overloaded-unary-and.cpp | 14 +++--- .../test/clang-tidy/google-readability-casting.c | 2 +- .../test/clang-tidy/google-readability-casting.cpp | 2 +- .../clang-tidy/google-readability-function.cpp | 2 +- .../google-readability-namespace-comments.cpp | 2 +- .../test/clang-tidy/google-readability-todo.cpp | 2 +- .../test/clang-tidy/google-runtime-int.cpp | 39 +++++++-------- .../test/clang-tidy/llvm-include-order.cpp | 2 +- .../test/clang-tidy/llvm-twine-local.cpp | 2 +- .../misc-bool-pointer-implicit-conversion.cpp | 2 +- .../test/clang-tidy/misc-swapped-arguments.cpp | 2 +- .../clang-tidy/misc-undelegated-constructor.cpp | 19 ++++---- .../test/clang-tidy/misc-unused-raii.cpp | 2 +- .../test/clang-tidy/misc-use-override.cpp | 2 +- ...dability-braces-around-statements-few-lines.cpp | 2 +- ...dability-braces-around-statements-same-line.cpp | 2 +- ...bility-braces-around-statements-single-line.cpp | 2 +- .../readability-braces-around-statements.cpp | 2 +- .../test/clang-tidy/readability-function-size.cpp | 55 ++++++++++------------ .../readability-redundant-smartptr-get.cpp | 2 +- 26 files changed, 139 insertions(+), 129 deletions(-) create mode 100755 clang-tools-extra/test/clang-tidy/check_clang_tidy.sh delete mode 100755 clang-tools-extra/test/clang-tidy/check_clang_tidy_fix.sh diff --git a/clang-tools-extra/test/clang-tidy/arg-comments.cpp b/clang-tools-extra/test/clang-tidy/arg-comments.cpp index 922c266..02dc83b 100644 --- a/clang-tools-extra/test/clang-tidy/arg-comments.cpp +++ b/clang-tools-extra/test/clang-tidy/arg-comments.cpp @@ -1,4 +1,5 @@ -// RUN: clang-tidy --checks='-*,misc-argument-comment' %s -- -std=c++11 | FileCheck %s -implicit-check-not='{{warning:|error:}}' +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-argument-comment %t +// REQUIRES: shell // FIXME: clang-tidy should provide a -verify mode to make writing these checks // easier and more accurate. @@ -7,10 +8,10 @@ void ffff(int xxxx, int yyyy); void f(int x, int y); void g() { - // CHECK: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x' - // CHECK: :[[@LINE-3]]:12: note: 'x' declared here - // CHECK: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y' - // CHECK: :[[@LINE-5]]:19: note: 'y' declared here + // CHECK-MESSAGES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x' + // CHECK-MESSAGES: :[[@LINE-3]]:12: note: 'x' declared here + // CHECK-MESSAGES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y' + // CHECK-MESSAGES: :[[@LINE-5]]:19: note: 'y' declared here f(/*y=*/0, /*z=*/0); } @@ -36,5 +37,5 @@ void variadic2(int zzz, Args&&... args); void templates() { variadic(/*xxx=*/0, /*yyy=*/1); variadic2(/*zzZ=*/0, /*xxx=*/1, /*yyy=*/2); - // CHECK: [[@LINE-1]]:13: warning: argument name 'zzZ' in comment does not match parameter name 'zzz' + // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument name 'zzZ' in comment does not match parameter name 'zzz' } diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.sh b/clang-tools-extra/test/clang-tidy/check_clang_tidy.sh new file mode 100755 index 0000000..0904d0d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Run clang-tidy in fix mode and verify fixes, messages or both. +# Usage: +# check_clang_tidy.sh \ +# [optional clang-tidy arguments] +# +# Example: +# // RUN: $(dirname %s)/check_clang_tidy.sh %s llvm-include-order %t -- -isystem $(dirname %s)/Inputs/Headers +# // REQUIRES: shell + +INPUT_FILE=$1 +CHECK_TO_RUN=$2 +TEMPORARY_FILE=$3.cpp +# Feed the rest arguments to clang-tidy. +shift 3 +if [ "$#" -eq 0 ] ; then + # Default to -- --std=c++11 + set - -- --std=c++11 +fi + +set -o errexit + +if ! grep -q 'CHECK-FIXES\|CHECK-MESSAGES' "${INPUT_FILE}"; then + echo "FAIL: Neither CHECK-FIXES nor CHECK-MESSAGES found in the input" + exit 1 +fi + +# Remove the contents of the CHECK lines to avoid CHECKs matching on themselves. +# We need to keep the comments to preserve line numbers while avoiding empty +# lines which could potentially trigger formatting-related checks. +sed 's#// *CHECK-[A-Z-]*:.*#//#' "${INPUT_FILE}" > "${TEMPORARY_FILE}" + +clang-tidy "${TEMPORARY_FILE}" -fix --checks="-*,${CHECK_TO_RUN}" "$@" \ + > "${TEMPORARY_FILE}.msg" 2>&1 + +if grep -q 'CHECK-FIXES' "${INPUT_FILE}"; then + FileCheck -input-file="${TEMPORARY_FILE}" "${INPUT_FILE}" \ + -check-prefix=CHECK-FIXES -strict-whitespace +fi + +if grep -q 'CHECK-MESSAGES' "${INPUT_FILE}"; then + FileCheck -input-file="${TEMPORARY_FILE}.msg" "${INPUT_FILE}" \ + -check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:' +fi diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy_fix.sh b/clang-tools-extra/test/clang-tidy/check_clang_tidy_fix.sh deleted file mode 100755 index cccabd5..0000000 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy_fix.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# Run clang-tidy in fix mode and verify the result. -# Usage: -# check_clang_tidy_fix.sh \ -# [optional clang-tidy arguments] -# -# Example: -# // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -- -isystem $(dirname %s)/Inputs/Headers -# // REQUIRES: shell - -INPUT_FILE=$1 -CHECK_TO_RUN=$2 -TEMPORARY_FILE=$3.cpp -# Feed the rest arguments to clang-tidy. -shift 3 -if [ "$#" -eq 0 ] ; then - # Default to -- --std=c++11 - set - -- --std=c++11 -fi - -set -o errexit - -# Remove the contents of the CHECK lines to avoid CHECKs matching on themselves. -# We need to keep the comments to preserve line numbers while avoiding empty -# lines which could potentially trigger formatting-related checks. -sed 's#// *CHECK-[A-Z-]*:.*#//#' ${INPUT_FILE} > ${TEMPORARY_FILE} - -clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" "$@" \ - > ${TEMPORARY_FILE}.msg 2>&1 - -FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} \ - -check-prefix=CHECK-FIXES -strict-whitespace - -if grep -q CHECK-MESSAGES ${INPUT_FILE}; then - FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} \ - -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:" -fi diff --git a/clang-tools-extra/test/clang-tidy/google-explicit-make-pair.cpp b/clang-tools-extra/test/clang-tidy/google-explicit-make-pair.cpp index 895b8e6..c8256c3 100644 --- a/clang-tools-extra/test/clang-tidy/google-explicit-make-pair.cpp +++ b/clang-tools-extra/test/clang-tidy/google-explicit-make-pair.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-build-explicit-make-pair %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-build-explicit-make-pair %t // REQUIRES: shell namespace std { diff --git a/clang-tools-extra/test/clang-tidy/google-member-string-references.cpp b/clang-tools-extra/test/clang-tidy/google-member-string-references.cpp index 1536bad..6ce05cb 100644 --- a/clang-tools-extra/test/clang-tidy/google-member-string-references.cpp +++ b/clang-tools-extra/test/clang-tidy/google-member-string-references.cpp @@ -1,4 +1,5 @@ -// RUN: clang-tidy %s -checks='-*,google-runtime-member-string-references' -- | FileCheck %s -implicit-check-not="{{warning|error}}:" +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-runtime-member-string-references %t +// REQUIRES: shell namespace std { template @@ -12,7 +13,7 @@ class string {}; struct A { const std::string &s; -// CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. [google-runtime-member-string-references] }; struct B { @@ -28,14 +29,14 @@ struct D { D(); const T &s; const std::string &s2; -// CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous. }; D d; struct AA { const string &s; -// CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are dangerous. }; struct BB { diff --git a/clang-tools-extra/test/clang-tidy/google-memset-zero-length.cpp b/clang-tools-extra/test/clang-tidy/google-memset-zero-length.cpp index 91eae36..95d0d23 100644 --- a/clang-tools-extra/test/clang-tidy/google-memset-zero-length.cpp +++ b/clang-tools-extra/test/clang-tidy/google-memset-zero-length.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-runtime-memset %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-runtime-memset %t // REQUIRES: shell void *memset(void *, int, __SIZE_TYPE__); diff --git a/clang-tools-extra/test/clang-tidy/google-overloaded-unary-and.cpp b/clang-tools-extra/test/clang-tidy/google-overloaded-unary-and.cpp index ce3d55c..3871330 100644 --- a/clang-tools-extra/test/clang-tidy/google-overloaded-unary-and.cpp +++ b/clang-tools-extra/test/clang-tidy/google-overloaded-unary-and.cpp @@ -1,24 +1,26 @@ -// RUN: clang-tidy %s -checks='-*,google-runtime-operator' -- | FileCheck %s -implicit-check-not="{{warning|error}}:" +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-runtime-operator %t +// REQUIRES: shell struct Foo { void *operator&(); -// CHECK: :[[@LINE-1]]:3: warning: do not overload unary operator&, it is dangerous. +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator&, it is dangerous. [google-runtime-operator] }; template struct TFoo { T *operator&(); -// CHECK: :[[@LINE-1]]:3: warning: do not overload unary operator&, it is dangerous. +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator& }; TFoo tfoo; struct Bar; void *operator&(Bar &b); -// CHECK: :[[@LINE-1]]:1: warning: do not overload unary operator&, it is dangerous. +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not overload unary operator& +// No warnings on binary operators. struct Qux { - void *operator&(Qux &q); // no-warning + void *operator&(Qux &q); }; -void *operator&(Qux &q, Qux &r); // no-warning +void *operator&(Qux &q, Qux &r); diff --git a/clang-tools-extra/test/clang-tidy/google-readability-casting.c b/clang-tools-extra/test/clang-tidy/google-readability-casting.c index 87d1dfc..55ee095 100644 --- a/clang-tools-extra/test/clang-tidy/google-readability-casting.c +++ b/clang-tools-extra/test/clang-tidy/google-readability-casting.c @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t -- -x c +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-readability-casting %t -- -x c // REQUIRES: shell void f(const char *cpc) { diff --git a/clang-tools-extra/test/clang-tidy/google-readability-casting.cpp b/clang-tools-extra/test/clang-tidy/google-readability-casting.cpp index 414fa8b..97df300 100644 --- a/clang-tools-extra/test/clang-tidy/google-readability-casting.cpp +++ b/clang-tools-extra/test/clang-tidy/google-readability-casting.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-casting %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-readability-casting %t // REQUIRES: shell bool g() { return false; } diff --git a/clang-tools-extra/test/clang-tidy/google-readability-function.cpp b/clang-tools-extra/test/clang-tidy/google-readability-function.cpp index ae60f70..1c89019 100644 --- a/clang-tools-extra/test/clang-tidy/google-readability-function.cpp +++ b/clang-tools-extra/test/clang-tidy/google-readability-function.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-function %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-readability-function %t // REQUIRES: shell void Method(char *) { /* */ } diff --git a/clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp b/clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp index 5f55a36..d92af94 100644 --- a/clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp +++ b/clang-tools-extra/test/clang-tidy/google-readability-namespace-comments.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-namespace-comments %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-readability-namespace-comments %t // REQUIRES: shell // CHECK-MESSAGES: :[[@LINE+2]]:11: warning: namespace not terminated with a closing comment [google-readability-namespace-comments] diff --git a/clang-tools-extra/test/clang-tidy/google-readability-todo.cpp b/clang-tools-extra/test/clang-tidy/google-readability-todo.cpp index cd4cd91..9f4e3a8 100644 --- a/clang-tools-extra/test/clang-tidy/google-readability-todo.cpp +++ b/clang-tools-extra/test/clang-tidy/google-readability-todo.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-todo %t -config="{User: 'some user'}" -- +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-readability-todo %t -config="{User: 'some user'}" -- // REQUIRES: shell // TODOfix this1 diff --git a/clang-tools-extra/test/clang-tidy/google-runtime-int.cpp b/clang-tools-extra/test/clang-tidy/google-runtime-int.cpp index 44d1b65..3a344b8 100644 --- a/clang-tools-extra/test/clang-tidy/google-runtime-int.cpp +++ b/clang-tools-extra/test/clang-tidy/google-runtime-int.cpp @@ -1,13 +1,14 @@ -// RUN: clang-tidy -checks=-*,google-runtime-int %s -- -x c++ 2>&1 | FileCheck %s -implicit-check-not='{{warning:|error:}}' +// RUN: $(dirname %s)/check_clang_tidy.sh %s google-runtime-int %t +// REQUIRES: shell long a(); -// CHECK: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}' +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}' typedef unsigned long long uint64; // NOLINT long b(long = 1); -// CHECK: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}' -// CHECK: [[@LINE-2]]:8: warning: consider replacing 'long' with 'int{{..}}' +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}' +// CHECK-MESSAGES: [[@LINE-2]]:8: warning: consider replacing 'long' with 'int{{..}}' template void tmpl() { @@ -15,45 +16,45 @@ void tmpl() { } short bar(const short, unsigned short) { -// CHECK: [[@LINE-1]]:1: warning: consider replacing 'short' with 'int16' -// CHECK: [[@LINE-2]]:17: warning: consider replacing 'short' with 'int16' -// CHECK: [[@LINE-3]]:24: warning: consider replacing 'unsigned short' with 'uint16' +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'short' with 'int16' +// CHECK-MESSAGES: [[@LINE-2]]:17: warning: consider replacing 'short' with 'int16' +// CHECK-MESSAGES: [[@LINE-3]]:24: warning: consider replacing 'unsigned short' with 'uint16' long double foo = 42; uint64 qux = 42; unsigned short port; const unsigned short bar = 0; -// CHECK: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16' +// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16' long long *baar; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' const unsigned short &bara = bar; -// CHECK: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16' +// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16' long const long moo = 1; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' long volatile long wat = 42; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64' unsigned long y; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'unsigned long' with 'uint{{..}}' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long' with 'uint{{..}}' unsigned long long **const *tmp; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64' unsigned long long **const *&z = tmp; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64' unsigned short porthole; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'unsigned short' with 'uint16' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned short' with 'uint16' uint64 cast = (short)42; -// CHECK: [[@LINE-1]]:18: warning: consider replacing 'short' with 'int16' +// CHECK-MESSAGES: [[@LINE-1]]:18: warning: consider replacing 'short' with 'int16' #define l long l x; tmpl(); -// CHECK: [[@LINE-1]]:8: warning: consider replacing 'short' with 'int16' +// CHECK-MESSAGES: [[@LINE-1]]:8: warning: consider replacing 'short' with 'int16' } void p(unsigned short port); void qux() { short port; -// CHECK: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16' +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16' } diff --git a/clang-tools-extra/test/clang-tidy/llvm-include-order.cpp b/clang-tools-extra/test/clang-tidy/llvm-include-order.cpp index 4568cb72c..8c6f178 100644 --- a/clang-tools-extra/test/clang-tidy/llvm-include-order.cpp +++ b/clang-tools-extra/test/clang-tidy/llvm-include-order.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-include-order %t -- -isystem %S/Inputs/Headers +// RUN: $(dirname %s)/check_clang_tidy.sh %s llvm-include-order %t -- -isystem %S/Inputs/Headers // REQUIRES: shell // FIXME: Investigating. diff --git a/clang-tools-extra/test/clang-tidy/llvm-twine-local.cpp b/clang-tools-extra/test/clang-tidy/llvm-twine-local.cpp index f36544e..e388eea 100644 --- a/clang-tools-extra/test/clang-tidy/llvm-twine-local.cpp +++ b/clang-tools-extra/test/clang-tidy/llvm-twine-local.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-twine-local %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s llvm-twine-local %t // REQUIRES: shell namespace llvm { diff --git a/clang-tools-extra/test/clang-tidy/misc-bool-pointer-implicit-conversion.cpp b/clang-tools-extra/test/clang-tidy/misc-bool-pointer-implicit-conversion.cpp index 2a27e6c..c8a7de9 100644 --- a/clang-tools-extra/test/clang-tidy/misc-bool-pointer-implicit-conversion.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-bool-pointer-implicit-conversion.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-bool-pointer-implicit-conversion %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-bool-pointer-implicit-conversion %t // REQUIRES: shell bool *SomeFunction(); diff --git a/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp b/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp index 1d43a49..746ed57 100644 --- a/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-swapped-arguments.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-swapped-arguments %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-swapped-arguments %t // REQUIRES: shell void F(int, double); diff --git a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp b/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp index 09d683b..7bed88a 100644 --- a/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-undelegated-constructor.cpp @@ -1,4 +1,5 @@ -// RUN: clang-tidy -checks='-*,misc-undelegated-constructor' %s -- -std=c++11 2>&1 | FileCheck %s -implicit-check-not='{{warning:|error:}}' +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-undelegated-constructor %t +// REQUIRES: shell struct Ctor; Ctor foo(); @@ -9,18 +10,18 @@ struct Ctor { Ctor(int, int); Ctor(Ctor *i) { Ctor(); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead [misc-undelegated-constructor] Ctor(0); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? Ctor(1, 2); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? foo(); } }; Ctor::Ctor() { Ctor(1); -// CHECK: :[[@LINE-1]]:3: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: did you intend to call a delegated constructor? } Ctor::Ctor(int i) : Ctor(i, 1) {} // properly delegated. @@ -31,11 +32,11 @@ struct Dtor { Dtor(int, int); Dtor(Ctor *i) { Dtor(); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? Dtor(0); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? Dtor(1, 2); -// CHECK: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: did you intend to call a delegated constructor? } ~Dtor(); }; @@ -43,7 +44,7 @@ struct Dtor { struct Base {}; struct Derived : public Base { Derived() { Base(); } -// CHECK: :[[@LINE-1]]:15: warning: did you intend to call a delegated constructor? A temporary object is created here instead +// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: did you intend to call a delegated constructor? }; template diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-raii.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-raii.cpp index e32410f..89086b7 100644 --- a/clang-tools-extra/test/clang-tidy/misc-unused-raii.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-unused-raii.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-unused-raii %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-unused-raii %t // REQUIRES: shell struct Foo { diff --git a/clang-tools-extra/test/clang-tidy/misc-use-override.cpp b/clang-tools-extra/test/clang-tidy/misc-use-override.cpp index 63739ad..ade067f 100644 --- a/clang-tools-extra/test/clang-tidy/misc-use-override.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-use-override.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-use-override %t // REQUIRES: shell #define ABSTRACT = 0 diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp index d4a8781..acf0c15 100644 --- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-few-lines.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" -- +// RUN: $(dirname %s)/check_clang_tidy.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 4}]}" -- // REQUIRES: shell void do_something(const char *) {} diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-same-line.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-same-line.cpp index a4a32ca..a821ac7 100644 --- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-same-line.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-same-line.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 1}]}" -- +// RUN: $(dirname %s)/check_clang_tidy.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 1}]}" -- // REQUIRES: shell void do_something(const char *) {} diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-single-line.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-single-line.cpp index a9bf141..1547ef0 100644 --- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-single-line.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-single-line.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" -- +// RUN: $(dirname %s)/check_clang_tidy.sh %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" -- // REQUIRES: shell void do_something(const char *) {} diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp index 97bd05b..110adbc 100644 --- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-braces-around-statements %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s readability-braces-around-statements %t // REQUIRES: shell void do_something(const char *) {} diff --git a/clang-tools-extra/test/clang-tidy/readability-function-size.cpp b/clang-tools-extra/test/clang-tidy/readability-function-size.cpp index 526e272..53a3928 100644 --- a/clang-tools-extra/test/clang-tidy/readability-function-size.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-function-size.cpp @@ -1,58 +1,55 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: sed 's#// *[A-Z-][A-Z-]*:.*#//#' %s > %t/t.cpp -// RUN: echo '{ Checks: "-*,readability-function-size", CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}]}' > %t/.clang-tidy -// RUN: clang-tidy %t/t.cpp -- -std=c++11 2>&1 | FileCheck %s -implicit-check-not='{{warning:|error:|note:}}' +// RUN: $(dirname %s)/check_clang_tidy.sh %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 +// REQUIRES: shell void foo1() { } void foo2() {;} -// CHECK: warning: function 'foo2' exceeds recommended size/complexity thresholds -// CHECK: note: 1 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo2' exceeds recommended size/complexity thresholds [readability-function-size] +// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 1 statements (threshold 0) void foo3() { ; } -// CHECK: warning: function 'foo3' exceeds recommended size/complexity thresholds -// CHECK: note: 3 lines including whitespace and comments (threshold 0) -// CHECK: note: 1 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'foo3' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0) +// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 1 statements (threshold 0) void foo4(int i) { if (i) {} else; {} } -// CHECK: warning: function 'foo4' exceeds recommended size/complexity thresholds -// CHECK: note: 1 lines including whitespace and comments (threshold 0) -// CHECK: note: 3 statements (threshold 0) -// CHECK: note: 1 branches (threshold 0) +// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: function 'foo4' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 1 lines including whitespace and comments (threshold 0) +// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 3 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 branches (threshold 0) void foo5(int i) {for(;i;)while(i) do;while(i); } -// CHECK: warning: function 'foo5' exceeds recommended size/complexity thresholds -// CHECK: note: 2 lines including whitespace and comments (threshold 0) -// CHECK: note: 7 statements (threshold 0) -// CHECK: note: 3 branches (threshold 0) +// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'foo5' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0) +// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 7 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 3 branches (threshold 0) template T foo6(T i) {return i; } int x = foo6(0); -// CHECK: warning: function 'foo6' exceeds recommended size/complexity thresholds -// CHECK: note: 1 lines including whitespace and comments (threshold 0) -// CHECK: note: 1 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-3]]:25: warning: function 'foo6' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-4]]:25: note: 1 lines including whitespace and comments (threshold 0) +// CHECK-MESSAGES: :[[@LINE-5]]:25: note: 1 statements (threshold 0) void bar1() { [](){;;;;;;;;;;;if(1){}}(); } -// CHECK: warning: function 'bar1' exceeds recommended size/complexity thresholds -// CHECK: note: 3 lines including whitespace and comments (threshold 0) -// CHECK: note: 14 statements (threshold 0) -// CHECK: note: 1 branches (threshold 0) +// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'bar1' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0) +// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 14 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 1 branches (threshold 0) void bar2() { class A { void barx() {;;} }; } -// CHECK: warning: function 'bar2' exceeds recommended size/complexity thresholds -// CHECK: note: 3 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar2' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 3 statements (threshold 0) // -// CHECK: warning: function 'barx' exceeds recommended size/complexity thresholds -// CHECK: note: 2 statements (threshold 0) +// CHECK-MESSAGES: :[[@LINE-4]]:30: warning: function 'barx' exceeds recommended size/complexity +// CHECK-MESSAGES: :[[@LINE-5]]:30: note: 2 statements (threshold 0) diff --git a/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get.cpp b/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get.cpp index c69e1fa..ef3c47f 100644 --- a/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get.cpp @@ -1,4 +1,4 @@ -// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s readability-redundant-smartptr-get %t +// RUN: $(dirname %s)/check_clang_tidy.sh %s readability-redundant-smartptr-get %t // REQUIRES: shell #define NULL __null -- 2.7.4