[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +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}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
|
2017-03-01 18:17:32 +08:00
|
|
|
|
|
|
|
// Bad formatting is intentional, don't run clang-format over the whole file!
|
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
|
|
|
|
2017-03-01 18:17:32 +08:00
|
|
|
void foo7(int p1, int p2, int p3, int p4, int p5, int p6) {;}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo7' exceeds recommended size/complexity
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 1 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 6 parameters (threshold 5)
|
|
|
|
|
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)
|
2017-06-09 22:22:10 +08:00
|
|
|
|
|
|
|
#define macro() {int x; {int y; {int z;}}}
|
|
|
|
|
|
|
|
void baz0() { // 1
|
2017-06-16 21:07:47 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
|
2017-06-16 21:07:47 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
|
2017-06-09 22:22:10 +08:00
|
|
|
int a;
|
|
|
|
{ // 2
|
|
|
|
int b;
|
|
|
|
{ // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:5: note: nesting level 3 starts here (threshold 2)
|
|
|
|
int c;
|
|
|
|
{ // 4
|
|
|
|
int d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{ // 2
|
|
|
|
int e;
|
|
|
|
}
|
|
|
|
{ // 2
|
|
|
|
{ // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:5: note: nesting level 3 starts here (threshold 2)
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
macro()
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-27]]:6: note: 9 variables (threshold 1)
|
2017-06-16 21:07:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// check that nested if's are not reported. this was broken initially
|
|
|
|
void nesting_if() { // 1
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
|
2017-06-16 21:07:47 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
|
|
|
|
if (true) { // 2
|
|
|
|
int j;
|
|
|
|
} else if (true) { // 2
|
|
|
|
int j;
|
|
|
|
if (true) { // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
} else if (true) { // 2
|
|
|
|
int j;
|
|
|
|
if (true) { // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
} else if (true) { // 2
|
|
|
|
int j;
|
|
|
|
}
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
|
2017-06-16 21:07:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// however this should warn
|
|
|
|
void bad_if_nesting() { // 1
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
|
2017-06-16 21:07:47 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
|
|
|
|
if (true) { // 2
|
|
|
|
int j;
|
|
|
|
} else { // 2
|
|
|
|
if (true) { // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:15: note: nesting level 3 starts here (threshold 2)
|
|
|
|
int j;
|
|
|
|
} else { // 3
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: note: nesting level 3 starts here (threshold 2)
|
|
|
|
if (true) { // 4
|
|
|
|
int j;
|
|
|
|
} else { // 4
|
|
|
|
if (true) { // 5
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
|
2017-06-09 22:22:10 +08:00
|
|
|
}
|
[clang-tidy] readability-function-size: add VariableThreshold param.
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
llvm-svn: 329902
2018-04-12 20:06:42 +08:00
|
|
|
|
|
|
|
void variables_0() {
|
|
|
|
int i;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
|
|
|
|
void variables_1(int i) {
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
|
|
|
|
void variables_2(int i, int j) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
|
|
|
|
void variables_3() {
|
|
|
|
int i[2];
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_3' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
|
|
|
|
void variables_4() {
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'variables_4' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 2 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_5() {
|
|
|
|
int i, j;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_5' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_6() {
|
|
|
|
for (int i;;)
|
|
|
|
for (int j;;)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: warning: function 'variables_6' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 4 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 5 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 2 branches (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_7() {
|
|
|
|
if (int a = 1)
|
|
|
|
if (int b = 2)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: warning: function 'variables_7' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 4 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 7 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 2 branches (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_8() {
|
|
|
|
int a[2];
|
|
|
|
for (auto i : a)
|
|
|
|
for (auto j : a)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: warning: function 'variables_8' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 5 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 8 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 2 branches (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-10]]:6: note: 3 variables (threshold 1)
|
|
|
|
void variables_9() {
|
|
|
|
int a, b;
|
|
|
|
struct A {
|
|
|
|
A(int c, int d) {
|
|
|
|
int e, f;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: warning: function 'variables_9' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 7 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-10]]:6: note: 3 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-11]]:6: note: 2 variables (threshold 1)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:5: warning: function 'A' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-10]]:5: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-11]]:5: note: 1 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-12]]:5: note: 2 variables (threshold 1)
|
|
|
|
void variables_10() {
|
|
|
|
int a, b;
|
|
|
|
struct A {
|
|
|
|
int c;
|
|
|
|
int d;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: warning: function 'variables_10' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 6 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 2 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-10]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_11() {
|
|
|
|
struct S {
|
|
|
|
void bar() {
|
|
|
|
int a, b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: warning: function 'variables_11' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 6 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:10: warning: function 'bar' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:10: note: 2 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:10: note: 2 variables (threshold 1)
|
|
|
|
void variables_12() {
|
|
|
|
int v;
|
|
|
|
auto test = [](int a, int b) -> void {};
|
|
|
|
test({}, {});
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: warning: function 'variables_12' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 4 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 3 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_13() {
|
|
|
|
int v;
|
|
|
|
auto test = []() -> void {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
test();
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-8]]:6: warning: function 'variables_13' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: 7 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-10]]:6: note: 5 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-11]]:6: note: 2 variables (threshold 1)
|
|
|
|
void variables_14() {
|
|
|
|
(void)({int a = 12; a; });
|
|
|
|
(void)({int a = 12; a; });
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'variables_14' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 6 statements (threshold 0)
|
|
|
|
#define SWAP(x, y) ({__typeof__(x) temp = x; x = y; y = temp; })
|
|
|
|
void variables_15() {
|
|
|
|
int a = 10, b = 12;
|
|
|
|
SWAP(a, b);
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'variables_15' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 5 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 2 variables (threshold 1)
|
|
|
|
#define vardecl(type, name) type name;
|
|
|
|
void variables_16() {
|
|
|
|
vardecl(int, a);
|
|
|
|
vardecl(int, b);
|
|
|
|
}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'variables_16' exceeds recommended size/complexity thresholds [readability-function-size]
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 4 statements (threshold 0)
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 2 variables (threshold 1)
|