1// RUN: %check_clang_tidy %s google-readability-namespace-comments %t
2
3namespace n1 {
4namespace /* a comment */ n2 /* another comment */ {
5
6
7void f(); // So that the namespace isn't empty.
8
9
10// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with a closing comment [google-readability-namespace-comments]
11// CHECK-MESSAGES: :[[@LINE-7]]:27: note: namespace 'n2' starts here
12// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
13// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
14}}
15// CHECK-FIXES: } // namespace n2
16// CHECK-FIXES: } // namespace n1
17
18#define MACRO macro_expansion
19namespace MACRO {
20void f(); // So that the namespace isn't empty.
21// 1
22// 2
23// 3
24// 4
25// 5
26// 6
27// 7
28// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'MACRO' not terminated with
29// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'MACRO' starts here
30}
31// CHECK-FIXES: } // namespace MACRO
32
33namespace macro_expansion {
34void ff(); // So that the namespace isn't empty.
35// 1
36// 2
37// 3
38// 4
39// 5
40// 6
41// 7
42// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not terminated with
43// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts here
44}
45// CHECK-FIXES: } // namespace macro_expansion
46
47namespace [[deprecated("foo")]] namespace_with_attr {
48inline namespace inline_namespace {
49void g();
50// 1
51// 2
52// 3
53// 4
54// 5
55// 6
56// 7
57// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'inline_namespace' not terminated with
58// CHECK-MESSAGES: :[[@LINE-10]]:18: note: namespace 'inline_namespace' starts here
59}
60// CHECK-FIXES: } // namespace inline_namespace
61// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'namespace_with_attr' not terminated with
62// CHECK-MESSAGES: :[[@LINE-15]]:33: note: namespace 'namespace_with_attr' starts here
63}
64// CHECK-FIXES: } // namespace namespace_with_attr
65
66namespace [[deprecated]] {
67void h();
68// 1
69// 2
70// 3
71// 4
72// 5
73// 6
74// 7
75// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: anonymous namespace not terminated with
76// CHECK-MESSAGES: :[[@LINE-10]]:26: note: anonymous namespace starts here
77}
78// CHECK-FIXES: } // namespace{{$}}
79
80namespace [[]] {
81void hh();
82// 1
83// 2
84// 3
85// 4
86// 5
87// 6
88// 7
89// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: anonymous namespace not terminated with
90// CHECK-MESSAGES: :[[@LINE-10]]:16: note: anonymous namespace starts here
91}
92// CHECK-FIXES: } // namespace{{$}}
93
94namespace short1 {
95namespace short2 {
96// Namespaces covering 10 lines or fewer are exempt from this rule.
97
98
99
100
101
102}
103}
104
105namespace n3 {
106
107
108
109
110
111
112
113
114
115}; // namespace n3
116

source code of clang-tools-extra/test/clang-tidy/checkers/google/readability-namespace-comments.cpp