2015-10-22 22:54:50 +08:00
|
|
|
// 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
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void foo1() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void foo2() {;}
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void foo3() {
|
|
|
|
;
|
|
|
|
|
|
|
|
}
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void foo4(int i) { if (i) {} else; {}
|
|
|
|
}
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void foo5(int i) {for(;i;)while(i)
|
|
|
|
do;while(i);
|
|
|
|
}
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
template <typename T> T foo6(T i) {return i;
|
|
|
|
}
|
|
|
|
int x = foo6(0);
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void bar1() { [](){;;;;;;;;;;;if(1){}}();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2014-10-26 10:58:07 +08:00
|
|
|
// 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)
|
2014-09-15 20:48:25 +08:00
|
|
|
|
|
|
|
void bar2() { class A { void barx() {;;} }; }
|
2014-10-26 10:58:07 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar2' exceeds recommended size/complexity
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 3 statements (threshold 0)
|
2014-09-15 20:48:25 +08:00
|
|
|
//
|
2014-10-26 10:58:07 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:30: warning: function 'barx' exceeds recommended size/complexity
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:30: note: 2 statements (threshold 0)
|