1 | // RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: {readability-function-size.LineThreshold: 0, readability-function-size.StatementThreshold: 0, readability-function-size.BranchThreshold: 0, readability-function-size.ParameterThreshold: 5, readability-function-size.NestingThreshold: 2, readability-function-size.VariableThreshold: 1}}' -- -std=c++17 |
2 | |
3 | void structured_bindings() { |
4 | int a[2] = {1, 2}; |
5 | auto [x, y] = a; |
6 | } |
7 | // CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'structured_bindings' exceeds recommended size/complexity thresholds [readability-function-size] |
8 | // CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0) |
9 | // CHECK-MESSAGES: :[[@LINE-6]]:6: note: 2 statements (threshold 0) |
10 | // CHECK-MESSAGES: :[[@LINE-7]]:6: note: 3 variables (threshold 1) |
11 | |
12 | #define SWAP(x, y) ({auto& [x0, x1] = x; __typeof__(x) t = {x0, x1}; auto& [y0, y1] = y; auto& [t0, t1] = t; x0 = y0; x1 = y1; y0 = t0; y1 = t1; }) |
13 | void variables_13() { |
14 | int a[2] = {1, 2}; |
15 | int b[2] = {3, 4}; |
16 | SWAP(a, b); |
17 | } |
18 | // CHECK-MESSAGES: :[[@LINE-5]]:6: warning: function 'variables_13' exceeds recommended size/complexity thresholds [readability-function-size] |
19 | // CHECK-MESSAGES: :[[@LINE-6]]:6: note: 4 lines including whitespace and comments (threshold 0) |
20 | // CHECK-MESSAGES: :[[@LINE-7]]:6: note: 11 statements (threshold 0) |
21 | // CHECK-MESSAGES: :[[@LINE-8]]:6: note: 2 variables (threshold 1) |
22 | |