forked from OSchip/llvm-project
[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
This commit is contained in:
parent
6775ce3ad3
commit
106c8e0898
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Run clang-tidy in fix mode and verify fixes, messages or both.
|
||||
# Usage:
|
||||
# check_clang_tidy.sh <source-file> <check-name> <temp-file> \
|
||||
# [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
|
|
@ -1,38 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Run clang-tidy in fix mode and verify the result.
|
||||
# Usage:
|
||||
# check_clang_tidy_fix.sh <source-file> <check-name> <temp-file> \
|
||||
# [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
|
|
@ -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 {
|
||||
|
|
|
@ -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<typename T>
|
||||
|
@ -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<std::string> 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 {
|
||||
|
|
|
@ -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__);
|
||||
|
|
|
@ -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 <typename T>
|
||||
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<int> 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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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 *) { /* */ }
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <typename T>
|
||||
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<short>();
|
||||
// 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'
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 <typename T>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 *) {}
|
||||
|
|
|
@ -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 *) {}
|
||||
|
|
|
@ -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 *) {}
|
||||
|
|
|
@ -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 *) {}
|
||||
|
|
|
@ -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 <typename T> 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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue