xref: /llvm-project/clang/test/Format/access-modifiers.cpp (revision 60bf5826cfd3629b5200a8ab743d701c90f66af0)
1*60bf5826SAlbertas Vyšniauskas // RUN: grep -Ev "// *[A-Z-]+:" %s \
2*60bf5826SAlbertas Vyšniauskas // RUN:   | clang-format -style="{BasedOnStyle: LLVM, EmptyLineBeforeAccessModifier: LogicalBlock}" -lines=1:14 \
3*60bf5826SAlbertas Vyšniauskas // RUN:   | clang-format -style="{BasedOnStyle: LLVM, EmptyLineBeforeAccessModifier: Never}" -lines=14:40 \
4*60bf5826SAlbertas Vyšniauskas // RUN:   | FileCheck -strict-whitespace %s
5*60bf5826SAlbertas Vyšniauskas 
6*60bf5826SAlbertas Vyšniauskas // CHECK: int i
7*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^$}}
8*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
9*60bf5826SAlbertas Vyšniauskas // CHECK: }
10*60bf5826SAlbertas Vyšniauskas struct foo1 {
11*60bf5826SAlbertas Vyšniauskas   int i;
12*60bf5826SAlbertas Vyšniauskas 
13*60bf5826SAlbertas Vyšniauskas private:
14*60bf5826SAlbertas Vyšniauskas   int j;
15*60bf5826SAlbertas Vyšniauskas };
16*60bf5826SAlbertas Vyšniauskas 
17*60bf5826SAlbertas Vyšniauskas // CHECK: struct bar1
18*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
19*60bf5826SAlbertas Vyšniauskas // CHECK: }
20*60bf5826SAlbertas Vyšniauskas struct bar1 {
21*60bf5826SAlbertas Vyšniauskas private:
22*60bf5826SAlbertas Vyšniauskas   int i;
23*60bf5826SAlbertas Vyšniauskas   int j;
24*60bf5826SAlbertas Vyšniauskas };
25*60bf5826SAlbertas Vyšniauskas 
26*60bf5826SAlbertas Vyšniauskas // CHECK: int i
27*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
28*60bf5826SAlbertas Vyšniauskas // CHECK: }
29*60bf5826SAlbertas Vyšniauskas struct foo2 {
30*60bf5826SAlbertas Vyšniauskas   int i;
31*60bf5826SAlbertas Vyšniauskas 
32*60bf5826SAlbertas Vyšniauskas private:
33*60bf5826SAlbertas Vyšniauskas   int j;
34*60bf5826SAlbertas Vyšniauskas };
35*60bf5826SAlbertas Vyšniauskas 
36*60bf5826SAlbertas Vyšniauskas // CHECK: struct bar2
37*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
38*60bf5826SAlbertas Vyšniauskas // CHECK: }
39*60bf5826SAlbertas Vyšniauskas struct bar2 {
40*60bf5826SAlbertas Vyšniauskas private:
41*60bf5826SAlbertas Vyšniauskas   int i;
42*60bf5826SAlbertas Vyšniauskas   int j;
43*60bf5826SAlbertas Vyšniauskas };
44*60bf5826SAlbertas Vyšniauskas 
45*60bf5826SAlbertas Vyšniauskas // CHECK: int j
46*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
47*60bf5826SAlbertas Vyšniauskas // CHECK: }
48*60bf5826SAlbertas Vyšniauskas struct foo3 {
49*60bf5826SAlbertas Vyšniauskas   int i;
50*60bf5826SAlbertas Vyšniauskas   int j;
51*60bf5826SAlbertas Vyšniauskas 
52*60bf5826SAlbertas Vyšniauskas private:
53*60bf5826SAlbertas Vyšniauskas };
54*60bf5826SAlbertas Vyšniauskas 
55*60bf5826SAlbertas Vyšniauskas // CHECK: struct bar3
56*60bf5826SAlbertas Vyšniauskas // CHECK-NEXT: {{^private:$}}
57*60bf5826SAlbertas Vyšniauskas // CHECK: }
58*60bf5826SAlbertas Vyšniauskas struct bar3 {
59*60bf5826SAlbertas Vyšniauskas 
60*60bf5826SAlbertas Vyšniauskas private:
61*60bf5826SAlbertas Vyšniauskas   int i;
62*60bf5826SAlbertas Vyšniauskas   int j;
63*60bf5826SAlbertas Vyšniauskas };
64