1// RUN: %check_clang_tidy %s readability-function-size %t -- \
2// RUN: -config='{CheckOptions: { \
3// RUN: readability-function-size.LineThreshold: 0, \
4// RUN: readability-function-size.StatementThreshold: 0, \
5// RUN: readability-function-size.BranchThreshold: 0, \
6// RUN: readability-function-size.ParameterThreshold: 5, \
7// RUN: readability-function-size.NestingThreshold: 2, \
8// RUN: readability-function-size.VariableThreshold: 1, \
9// RUN: readability-function-size.CountMemberInitAsStmt: false \
10// RUN: }}'
11
12// Bad formatting is intentional, don't run clang-format over the whole file!
13
14void foo1() {
15}
16
17void foo2() {;}
18// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo2' exceeds recommended size/complexity thresholds [readability-function-size]
19// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 1 statements (threshold 0)
20
21struct A {
22 A(int c, int d) : a(0), b(c) { ; }
23 int a;
24 int b;
25};
26// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: function 'A' exceeds recommended size/complexity thresholds [readability-function-size]
27// CHECK-MESSAGES: :[[@LINE-5]]:3: note: 1 statements (threshold 0)
28
29struct B {
30 B(int x, int y, int z) : a(x + y * z), b(), c_a(y, z) {
31 ;
32 }
33 int a;
34 int b;
35 A c_a;
36};
37// CHECK-MESSAGES: :[[@LINE-7]]:3: warning: function 'B' exceeds recommended size/complexity thresholds [readability-function-size]
38// CHECK-MESSAGES: :[[@LINE-8]]:3: note: 2 lines including whitespace and comments (threshold 0)
39// CHECK-MESSAGES: :[[@LINE-9]]:3: note: 1 statements (threshold 0)
40
41struct C : A, B {
42 // 0 statements
43 C() : A(0, 4), B(1, 2, 3) {}
44};
45
46template<typename T>
47struct TemplateC {
48 // 0 statements
49 TemplateC() : a(3) {}
50 T a;
51};
52
53template<typename T>
54struct TemplateD {
55 template<typename U>
56 TemplateD(U&& val) : member(val) {
57 ;
58 }
59
60 T member;
61};
62// CHECK-MESSAGES: :[[@LINE-6]]:3: warning: function 'TemplateD<T>' exceeds recommended size/complexity thresholds [readability-function-size]
63// CHECK-MESSAGES: :[[@LINE-7]]:3: note: 2 lines including whitespace and comments (threshold 0)
64// CHECK-MESSAGES: :[[@LINE-8]]:3: note: 1 statements (threshold 0)
65
66void instantiate() {
67 TemplateC<int> c;
68 TemplateD<int> d(5);
69}
70// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'instantiate' exceeds recommended size/complexity thresholds [readability-function-size]
71// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 3 lines including whitespace and comments (threshold 0)
72// CHECK-MESSAGES: :[[@LINE-6]]:6: note: 2 statements (threshold 0)
73// CHECK-MESSAGES: :[[@LINE-7]]:6: note: 2 variables (threshold 1)
74

source code of clang-tools-extra/test/clang-tidy/checkers/readability/function-size-no-member-init-as-stmts.cpp