aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability/function-size-no-member-init-as-stmts.cpp
blob: d335988e5e033e962fd90126097ce983da24db51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: %check_clang_tidy %s readability-function-size %t -- \
// RUN:     -config='{CheckOptions: { \
// RUN:         readability-function-size.LineThreshold: 0, \
// RUN:         readability-function-size.StatementThreshold: 0, \
// RUN:         readability-function-size.BranchThreshold: 0, \
// RUN:         readability-function-size.ParameterThreshold: 5, \
// RUN:         readability-function-size.NestingThreshold: 2, \
// RUN:         readability-function-size.VariableThreshold: 1, \
// RUN:         readability-function-size.CountMemberInitAsStmt: false \
// RUN:     }}'

// Bad formatting is intentional, don't run clang-format over the whole file!

void foo1() {
}

void foo2() {;}
// 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)

struct A {
  A(int c, int d) : a(0), b(c) { ; }
  int a;
  int b;
};
// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: function 'A' exceeds recommended size/complexity thresholds [readability-function-size]
// CHECK-MESSAGES: :[[@LINE-5]]:3: note: 1 statements (threshold 0)

struct B {
  B(int x, int y, int z) : a(x + y * z), b(), c_a(y, z) {
    ;
  }
  int a;
  int b;
  A c_a;
};
// CHECK-MESSAGES: :[[@LINE-7]]:3: warning: function 'B' exceeds recommended size/complexity thresholds [readability-function-size]
// CHECK-MESSAGES: :[[@LINE-8]]:3: note: 2 lines including whitespace and comments (threshold 0)
// CHECK-MESSAGES: :[[@LINE-9]]:3: note: 1 statements (threshold 0)

struct C : A, B {
  // 0 statements
  C() : A(0, 4), B(1, 2, 3) {}
};

template<typename T>
struct TemplateC {
  // 0 statements
  TemplateC() : a(3) {}
  T a;
};

template<typename T>
struct TemplateD {
  template<typename U>
  TemplateD(U&& val) : member(val) { 
    ;
  }
  
  T member;
};
// CHECK-MESSAGES: :[[@LINE-6]]:3: warning: function 'TemplateD<T>' exceeds recommended size/complexity thresholds [readability-function-size]
// CHECK-MESSAGES: :[[@LINE-7]]:3: note: 2 lines including whitespace and comments (threshold 0)
// CHECK-MESSAGES: :[[@LINE-8]]:3: note: 1 statements (threshold 0)

void instantiate() {
  TemplateC<int> c;
  TemplateD<int> d(5);
}
// CHECK-MESSAGES: :[[@LINE-4]]:6: warning: function 'instantiate' 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)