Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | // RUN: %check_clang_tidy %s llvmlibc-inline-function-decl %t |
---|---|
2 | |
3 | #ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H |
4 | #define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H |
5 | |
6 | #define LIBC_INLINE inline |
7 | |
8 | namespace __llvm_libc { |
9 | |
10 | LIBC_INLINE int addi(int a, int b) { |
11 | return a + b; |
12 | } |
13 | |
14 | LIBC_INLINE constexpr long addl(long a, long b) { |
15 | return a + b; |
16 | } |
17 | |
18 | constexpr long long addll(long long a, long long b) { |
19 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
20 | // CHECK-FIXES: LIBC_INLINE constexpr long long addll(long long a, long long b) { |
21 | return a + b; |
22 | } |
23 | |
24 | inline unsigned long addul(unsigned long a, unsigned long b) { |
25 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addul' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
26 | // CHECK-FIXES: LIBC_INLINE inline unsigned long addul(unsigned long a, unsigned long b) { |
27 | return a + b; |
28 | } |
29 | |
30 | class MyClass { |
31 | int A; |
32 | public: |
33 | MyClass() : A(123) {} |
34 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'MyClass' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
35 | // CHECK-FIXES: LIBC_INLINE MyClass() : A(123) {} |
36 | |
37 | LIBC_INLINE MyClass(int V) : A(V) {} |
38 | |
39 | constexpr operator int() const { return A; } |
40 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator int' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
41 | // CHECK-FIXES: LIBC_INLINE constexpr operator int() const { return A; } |
42 | |
43 | LIBC_INLINE bool operator==(const MyClass &RHS) { |
44 | return RHS.A == A; |
45 | } |
46 | |
47 | static int getVal(const MyClass &V) { |
48 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'getVal' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
49 | // CHECK-FIXES: LIBC_INLINE static int getVal(const MyClass &V) { |
50 | return V.A; |
51 | } |
52 | |
53 | LIBC_INLINE static void setVal(MyClass &V, int A) { |
54 | V.A = A; |
55 | } |
56 | |
57 | constexpr static int addInt(MyClass &V, int A) { |
58 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'addInt' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
59 | // CHECK-FIXES: LIBC_INLINE constexpr static int addInt(MyClass &V, int A) { |
60 | return V.A += A; |
61 | } |
62 | |
63 | static LIBC_INLINE int mulInt(MyClass &V, int A) { |
64 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'mulInt' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
65 | return V.A *= A; |
66 | } |
67 | }; |
68 | |
69 | LIBC_INLINE void lambda() { |
70 | // CHECK-MESSAGES-NOT: :[[@LINE+4]]:3: warning: '__invoke' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
71 | // CHECK-MESSAGES-NOT: :[[@LINE+3]]:3: warning: 'operator void (*)()' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
72 | // CHECK-MESSAGES-NOT: :[[@LINE+2]]:3: warning: '~(lambda at [[FILENAME:.+]])' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
73 | // CHECK-MESSAGES-NOT: :[[@LINE+1]]:6: warning: 'operator()' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
74 | [](){}; |
75 | } |
76 | |
77 | namespace issue_62746 { |
78 | |
79 | void goodSimpleFunction(); |
80 | void badSimpleFunction(); |
81 | void badSimpleFunctionWrongLocation(); |
82 | |
83 | LIBC_INLINE void goodSimpleFunction() {} |
84 | |
85 | inline void badSimpleFunction() {} |
86 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
87 | // CHECK-FIXES: LIBC_INLINE inline void badSimpleFunction() {} |
88 | |
89 | void LIBC_INLINE badSimpleFunctionWrongLocation() {} |
90 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
91 | |
92 | template <typename T> |
93 | void goodTemplateFunction(); |
94 | template <typename T> |
95 | void badTemplateFunction(); |
96 | template <typename T> |
97 | void badTemplateFunctionWrongLocation(); |
98 | |
99 | template <typename T> LIBC_INLINE void goodTemplateFunction() {} |
100 | |
101 | template <typename T> inline void badTemplateFunction() {} |
102 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
103 | // CHECK-FIXES: template <typename T> LIBC_INLINE inline void badTemplateFunction() {} |
104 | |
105 | template <typename T> void LIBC_INLINE badTemplateFunctionWrongLocation() {} |
106 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
107 | |
108 | template <typename... Ts> |
109 | void goodVariadicFunction(); |
110 | template <typename... Ts> |
111 | void badVariadicFunction(); |
112 | template <typename... Ts> |
113 | void badVariadicFunctionWrongLocation(); |
114 | |
115 | template <typename... Ts> LIBC_INLINE void goodVariadicFunction() {} |
116 | |
117 | template <typename... Ts> inline void badVariadicFunction() {} |
118 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
119 | // CHECK-FIXES: template <typename... Ts> LIBC_INLINE inline void badVariadicFunction() {} |
120 | |
121 | template <typename... Ts> void LIBC_INLINE badVariadicFunctionWrongLocation() {} |
122 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
123 | // CHECK-FIXES: template <typename... Ts> LIBC_INLINE void LIBC_INLINE badVariadicFunctionWrongLocation() {} |
124 | |
125 | struct NoTemplate { |
126 | void goodNoTemplate(); |
127 | void badNoTemplate(); |
128 | void badNoTemplateWrongLocation(); |
129 | |
130 | template <typename T> |
131 | void goodNestedTemplate(); |
132 | template <typename T> |
133 | void badNestedTemplate(); |
134 | template <typename T> |
135 | void badNestedTemplateWrongLocation(); |
136 | |
137 | template <typename... Ts> |
138 | void goodVariadicTemplate(); |
139 | template <typename... Ts> |
140 | void badVariadicTemplate(); |
141 | template <typename... Ts> |
142 | void badVariadicTemplateWrongLocation(); |
143 | |
144 | }; |
145 | |
146 | LIBC_INLINE void NoTemplate::goodNoTemplate() {} |
147 | |
148 | inline void NoTemplate::badNoTemplate() {} |
149 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badNoTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
150 | // CHECK-FIXES: LIBC_INLINE inline void NoTemplate::badNoTemplate() {} |
151 | |
152 | void LIBC_INLINE NoTemplate::badNoTemplateWrongLocation() {} |
153 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badNoTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
154 | // CHECK-FIXES: LIBC_INLINE void LIBC_INLINE NoTemplate::badNoTemplateWrongLocation() {} |
155 | |
156 | template <typename T> LIBC_INLINE void NoTemplate::goodNestedTemplate() {} |
157 | |
158 | template <typename T> inline void NoTemplate::badNestedTemplate() {} |
159 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
160 | // CHECK-FIXES: template <typename T> LIBC_INLINE inline void NoTemplate::badNestedTemplate() {} |
161 | |
162 | template <typename T> void LIBC_INLINE NoTemplate::badNestedTemplateWrongLocation() {} |
163 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
164 | // CHECK-FIXES: template <typename T> LIBC_INLINE void LIBC_INLINE NoTemplate::badNestedTemplateWrongLocation() {} |
165 | |
166 | template <typename... Ts> LIBC_INLINE void NoTemplate::goodVariadicTemplate() {} |
167 | |
168 | template <typename... Ts> void inline NoTemplate::badVariadicTemplate() {} |
169 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
170 | // CHECK-FIXES: template <typename... Ts> LIBC_INLINE void inline NoTemplate::badVariadicTemplate() {} |
171 | |
172 | template <typename... Ts> void LIBC_INLINE NoTemplate::badVariadicTemplateWrongLocation() {} |
173 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
174 | |
175 | template <typename T> |
176 | struct SimpleTemplate { |
177 | void goodSimpleTemplate(); |
178 | void badSimpleTemplate(); |
179 | void badSimpleTemplateWrongLocation(); |
180 | |
181 | template <typename U> |
182 | void goodNestedTemplate(); |
183 | template <typename U> |
184 | void badNestedTemplate(); |
185 | template <typename U> |
186 | void badNestedTemplateWrongLocation(); |
187 | |
188 | template <typename... Ts> |
189 | void goodNestedVariadicTemplate(); |
190 | template <typename... Ts> |
191 | void badNestedVariadicTemplate(); |
192 | template <typename... Ts> |
193 | void badNestedVariadicTemplateWrongLocation(); |
194 | }; |
195 | |
196 | template <typename T> LIBC_INLINE void SimpleTemplate<T>::goodSimpleTemplate() {} |
197 | |
198 | template <typename T> inline void SimpleTemplate<T>::badSimpleTemplate() {} |
199 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badSimpleTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
200 | // CHECK-FIXES: template <typename T> LIBC_INLINE inline void SimpleTemplate<T>::badSimpleTemplate() {} |
201 | |
202 | template <typename T> void LIBC_INLINE SimpleTemplate<T>::badSimpleTemplateWrongLocation() {} |
203 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badSimpleTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
204 | |
205 | template <typename T> template <typename U> LIBC_INLINE void SimpleTemplate<T>::goodNestedTemplate() {} |
206 | |
207 | template <typename T> template <typename U> inline void SimpleTemplate<T>::badNestedTemplate() {} |
208 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
209 | // CHECK-FIXES: template <typename T> template <typename U> LIBC_INLINE inline void SimpleTemplate<T>::badNestedTemplate() {} |
210 | |
211 | template <typename T> template <typename U> void LIBC_INLINE SimpleTemplate<T>::badNestedTemplateWrongLocation() {} |
212 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
213 | |
214 | template <typename T> template <typename... Ts> LIBC_INLINE void SimpleTemplate<T>::goodNestedVariadicTemplate() {} |
215 | |
216 | template <typename T> template <typename... Ts> inline void SimpleTemplate<T>::badNestedVariadicTemplate() {} |
217 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
218 | // CHECK-FIXES: template <typename T> template <typename... Ts> LIBC_INLINE inline void SimpleTemplate<T>::badNestedVariadicTemplate() {} |
219 | |
220 | template <typename T> template <typename... Ts> void LIBC_INLINE SimpleTemplate<T>::badNestedVariadicTemplateWrongLocation() {} |
221 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
222 | |
223 | template <typename... Ts> |
224 | struct VariadicTemplate { |
225 | void goodVariadicTemplate(); |
226 | void badVariadicTemplate(); |
227 | void badVariadicTemplateWrongLocation(); |
228 | |
229 | template <typename U> |
230 | void goodNestedTemplate(); |
231 | template <typename U> |
232 | void badNestedTemplate(); |
233 | template <typename U> |
234 | void badNestedTemplateWrongLocation(); |
235 | |
236 | template <typename... Us> |
237 | void goodNestedVariadicTemplate(); |
238 | template <typename... Us> |
239 | void badNestedVariadicTemplate(); |
240 | template <typename... Us> |
241 | void badNestedVariadicTemplateWrongLocation(); |
242 | }; |
243 | |
244 | template <typename... Ts> LIBC_INLINE void VariadicTemplate<Ts...>::goodVariadicTemplate() {} |
245 | |
246 | template <typename... Ts> inline void VariadicTemplate<Ts...>::badVariadicTemplate() {} |
247 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
248 | // CHECK-FIXES: template <typename... Ts> LIBC_INLINE inline void VariadicTemplate<Ts...>::badVariadicTemplate() {} |
249 | |
250 | template <typename... Ts> void LIBC_INLINE VariadicTemplate<Ts...>::badVariadicTemplateWrongLocation() {} |
251 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
252 | |
253 | template <typename... Ts> template <typename U> LIBC_INLINE void VariadicTemplate<Ts...>::goodNestedTemplate() {} |
254 | |
255 | template <typename... Ts> template <typename U> inline void VariadicTemplate<Ts...>::badNestedTemplate() {} |
256 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
257 | // CHECK-FIXES: template <typename... Ts> template <typename U> LIBC_INLINE inline void VariadicTemplate<Ts...>::badNestedTemplate() {} |
258 | |
259 | template <typename... Ts> template <typename U> void LIBC_INLINE VariadicTemplate<Ts...>::badNestedTemplateWrongLocation() {} |
260 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
261 | |
262 | template <typename... Ts> template <typename... Us> LIBC_INLINE void VariadicTemplate<Ts...>::goodNestedVariadicTemplate() {} |
263 | |
264 | template <typename... Ts> template <typename... Us> inline void VariadicTemplate<Ts...>::badNestedVariadicTemplate() {} |
265 | // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: 'badNestedVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
266 | // CHECK-FIXES: template <typename... Ts> template <typename... Us> LIBC_INLINE inline void VariadicTemplate<Ts...>::badNestedVariadicTemplate() {} |
267 | |
268 | template <typename... Ts> template <typename... Us> void LIBC_INLINE VariadicTemplate<Ts...>::badNestedVariadicTemplateWrongLocation() {} |
269 | // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: 'badNestedVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
270 | |
271 | template <typename T> |
272 | void goodWeirdFormatting(); |
273 | template <typename T> |
274 | void badWeirdFormatting(); |
275 | |
276 | template <typename T>LIBC_INLINE void goodWeirdFormatting() {} |
277 | |
278 | template <typename T>void LIBC_INLINE badWeirdFormatting() {} |
279 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 'badWeirdFormatting' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
280 | |
281 | |
282 | template <unsigned int NumberOfBits> struct HasMemberAndTemplate { |
283 | char Data[NumberOfBits]; |
284 | |
285 | void explicitFunction() {} |
286 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'explicitFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
287 | // CHECK-FIXES: LIBC_INLINE void explicitFunction() {} |
288 | }; |
289 | |
290 | static auto instanceOfStruct = HasMemberAndTemplate<16>(); |
291 | |
292 | struct HasMemberAndExplicitDefault { |
293 | int TrivialMember; |
294 | |
295 | HasMemberAndExplicitDefault() = default; |
296 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'HasMemberAndExplicitDefault' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] |
297 | // CHECK-FIXES: LIBC_INLINE HasMemberAndExplicitDefault() = default; |
298 | |
299 | ~HasMemberAndExplicitDefault() = delete; |
300 | }; |
301 | |
302 | |
303 | } // namespace issue_62746 |
304 | |
305 | } // namespace __llvm_libc |
306 | |
307 | #endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H |
308 |
Warning: That file was not part of the compilation database. It may have many parsing errors.