-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaliceO2-namespace-naming.cpp
More file actions
218 lines (183 loc) · 7.25 KB
/
aliceO2-namespace-naming.cpp
File metadata and controls
218 lines (183 loc) · 7.25 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// RUN: %check_clang_tidy %s aliceO2-namespace-naming %t
namespace {}
namespace{
}
namespace
{
namespace simple
{
};
};
namespace o2
{
}
namespace o2codecheck
{
}
namespace a_1234_5678_b
{
}
namespace TPC
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'TPC' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace tpc{{$}}
{
}
using namespace TPC;
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: namespace 'TPC' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}using namespace tpc;{{$}}
namespace OuterNamespaceWrong
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'OuterNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace outer_namespace_wrong{{$}}
{
namespace InnerNamespaceWrong
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'InnerNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace inner_namespace_wrong{{$}}
{
class InnerClass
{
public:
int a;
};
};
};
namespace outer_namespace_correct
{
namespace inner_namespace_correct
{
class InnerClass
{
public:
int b;
};
};
};
using namespace OuterNamespaceWrong::InnerNamespaceWrong;
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: namespace 'OuterNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-MESSAGES: :[[@LINE-2]]:38: warning: namespace 'InnerNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}using namespace outer_namespace_wrong::inner_namespace_wrong;{{$}}
using namespace outer_namespace_correct::inner_namespace_correct;
typedef OuterNamespaceWrong::InnerNamespaceWrong::InnerClass JustInnerClass1;
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: namespace 'OuterNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: namespace 'InnerNamespaceWrong' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}typedef outer_namespace_wrong::inner_namespace_wrong::InnerClass JustInnerClass1;{{$}}
typedef outer_namespace_correct::inner_namespace_correct::InnerClass JustInnerClass2;
namespace FirstNamespace
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace first_namespace{{$}}
{
int a;
void fooFromNamespace();
void bar()
{
}
class NamespaceClassForLaterDefinition;
class NamespaceClass
{
static int c1;
public:
static int bb;
static int getC1();
int getC1NotStatic();
class NamespaceClassInnerClass
{
int c2;
public:
int c3;
static int c4;
static int getC2();
int getC2NotStatic();
void dummy1()
{
NamespaceClass::bb=2;
}
};
};
};
class FirstNamespace::NamespaceClassForLaterDefinition
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}class first_namespace::NamespaceClassForLaterDefinition{{$}}
{
int justSomething;
};
namespace Singleword
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'Singleword' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace singleword{{$}}
{
};
namespace Double_Words
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'Double_Words' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace double_words{{$}}
{
};
namespace secondNamespace
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'secondNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}namespace second_namespace{{$}}
{
int b;
};
class FirstClass
{
int fooVar;
public:
void fooFromClass();
};
struct FirstStruct
{
int fooVar;
public:
void fooFromStruct();
};
int FirstNamespace::NamespaceClass::getC1()
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}int first_namespace::NamespaceClass::getC1(){{$}}
{
return c1;
}
void FirstClass::fooFromClass()
{
}
void FirstStruct::fooFromStruct()
{
}
void FirstNamespace::fooFromNamespace(); // just forward declaration
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}void first_namespace::fooFromNamespace(); // just forward declaration{{$}}
void FirstNamespace::fooFromNamespace() // definition
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}}void first_namespace::fooFromNamespace() // definition{{$}}
{
}
void dummy1(int par1)
{
}
int main()
{
FirstNamespace::a=5;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} first_namespace::a=5;{{$}}
dummy1(FirstNamespace::a);
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} dummy1(first_namespace::a);{{$}}
int temp = FirstNamespace::NamespaceClass::getC1();
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} int temp = first_namespace::NamespaceClass::getC1();{{$}}
FirstNamespace::NamespaceClass classInstance;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} first_namespace::NamespaceClass classInstance;{{$}}
temp = classInstance.getC1NotStatic();
temp = FirstNamespace::NamespaceClass::NamespaceClassInnerClass::getC2();
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} temp = first_namespace::NamespaceClass::NamespaceClassInnerClass::getC2();{{$}}
FirstNamespace::NamespaceClass::NamespaceClassInnerClass classInstance2;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} first_namespace::NamespaceClass::NamespaceClassInnerClass classInstance2;{{$}}
temp = classInstance2.getC2NotStatic();
temp = classInstance2.c3;
temp = FirstNamespace::NamespaceClass::NamespaceClassInnerClass::c4;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: namespace 'FirstNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} temp = first_namespace::NamespaceClass::NamespaceClassInnerClass::c4;{{$}}
secondNamespace::b=166;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: namespace 'secondNamespace' does not follow the underscore convention [aliceO2-namespace-naming]
// CHECK-FIXES: {{^}} second_namespace::b=166;{{$}}
return 0;
}