Lines Matching full:contains

1 // RUN: %check_clang_tidy -std=c++11-or-later %s readability-container-contains %t
14 bool contains(const Key &K) const;
22 bool contains(const Key &K) const;
28 bool contains(const Key &K) const;
34 bool contains(const Key &K) const;
42 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use 'contains' to check for membership [readability-container-contains]
43 // CHECK-FIXES: if (MyMap.contains(0))
46 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
47 // CHECK-FIXES: bool C1 = MyMap.contains(1);
49 // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use 'contains' to check for membership [readability-container-contains]
50 // CHECK-FIXES: auto C2 = static_cast<bool>(MyMap.contains(1));
52 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
53 // CHECK-FIXES: auto C3 = MyMap.contains(2);
55 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
56 // CHECK-FIXES: auto C4 = MyMap.contains(3);
58 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
59 // CHECK-FIXES: auto C5 = MyMap.contains(4);
61 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
62 // CHECK-FIXES: auto C6 = MyMap.contains(5);
69 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use 'contains' to check for membership [readability-container-contains]
70 // CHECK-FIXES: bool C1 = !MyMap.contains(-1);
72 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
73 // CHECK-FIXES: auto C2 = !MyMap.contains(-2);
75 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
76 // CHECK-FIXES: auto C3 = !MyMap.contains(-3);
78 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
79 // CHECK-FIXES: auto C4 = !MyMap.contains(-4);
81 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
82 // CHECK-FIXES: auto C5 = !MyMap.contains(-5);
89 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use 'contains' to check for membership [readability-container-contains]
90 // CHECK-FIXES: bool C1 = M.contains(1001);
92 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use 'contains' to check for membership [readability-container-contains]
93 // CHECK-FIXES: bool C2 = US.contains(1002);
95 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use 'contains' to check for membership [readability-container-contains]
96 // CHECK-FIXES: bool C3 = S.contains(1003);
98 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use 'contains' to check for membership [readability-container-contains]
99 // CHECK-FIXES: bool C4 = MM.contains(1004);
106 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use 'contains' to check for membership [readability-container-contains]
107 // CHECK-FIXES: bool C1 = ValueM.contains(2001);
109 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use 'contains' to check for membership [readability-container-contains]
110 // CHECK-FIXES: bool C2 = RefM.contains(2002);
112 // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use 'contains' to check for membership [readability-container-contains]
113 // CHECK-FIXES: bool C3 = ConstRefM.contains(2003);
115 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use 'contains' to check for membership [readability-container-contains]
116 // CHECK-FIXES: bool C4 = RValueM.contains(2004);
124 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use 'contains' to check for membership [readability-container-contains]
125 // CHECK-FIXES: return M.contains(42);
140 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
141 // CHECK-FIXES: bool C1 = MyMap.contains(99);
151 // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use 'contains' to check for membership [readability-container-contains]
152 // CHECK-FIXES: return LocalM.contains(42);
163 // don't accidentally rewrite it to 'contains'.
173 // This could theoretically be rewritten into a 'contains' after removig the
187 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
188 // CHECK-FIXES: auto C1 = MyMap.contains(2);
190 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
191 // CHECK-FIXES: auto C2 = MyMap.contains(2);
193 // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for membership [readability-container-contains]
194 // CHECK-FIXES: auto C3 = MyMap.contains(2);
196 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for membership [readability-container-contains]
197 // CHECK-FIXES: auto C4 = MyMap.contains(2);
199 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
200 // CHECK-FIXES: auto C5 = !MyMap.contains(2);
202 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
203 // CHECK-FIXES: auto C6 = !MyMap.contains(2);
205 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for membership [readability-container-contains]
206 // CHECK-FIXES: auto C7 = !MyMap.contains(2);
208 // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for membership [readability-container-contains]
209 // CHECK-FIXES: auto C8 = !MyMap.contains(2);
214 // We don't want to rewrite if the `contains` call is from a macro expansion
221 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use 'contains' to check for membership [readability-container-contains]
231 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use 'contains' to check for membership [readability-container-contains]
240 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use 'contains' to check for membership [readability-container-contains]
241 // CHECK-FIXES: if (MY_SET.contains(1)) {
252 bool contains(const Key &K) const;
259 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
260 // CHECK-FIXES: if (MyMap.contains(0)) {};
263 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
264 // CHECK-FIXES: MyMap.contains(0);
271 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
272 // CHECK-FIXES: if (MyMap.contains(0)) {};
281 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
282 // CHECK-FIXES: if (MyMap.contains(0)) {};
288 bool contains(const Key &K) const = delete;
297 // No warning if the `contains` method is deleted.
309 bool contains(const Key &K) const;
316 // No warning if the `contains` method is not public.
325 bool contains(const MyString&) const;
329 // No warning if there is no `contains` method with the right type.
337 bool contains(ConstPtrType Ptr) const;
344 bool contains(ConstPtrType Ptr) const;
351 bool contains(ConstPtrType Ptr) const;
359 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
360 // CHECK-FIXES: if (MySet.contains(**Ptr)) {};
362 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
363 // CHECK-FIXES: if (MySet2.contains(*Ptr)) {};
365 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
366 // CHECK-FIXES: if (MySet3.contains(Ptr)) {};
374 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
375 // CHECK-FIXES: if (Set.contains(Entry)) {}
380 bool contains(int* Ptr) const;
389 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
390 // CHECK-FIXES: if (S.contains(U)) {}
396 bool contains(const T &K) const;
406 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
407 // CHECK-FIXES: if (MyMap.contains(A())) {};
411 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
412 // CHECK-FIXES: if (MyMap2.contains(C())) {};
415 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
416 // CHECK-FIXES: if (MyMap2.contains(C())) {};
425 bool contains(Box<T> K) const;
431 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
432 // CHECK-FIXES: if (Set.contains(0)) {};
437 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
438 // CHECK-FIXES: if (Map.contains(0)) {};
440 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
441 // CHECK-FIXES: if (Map.contains(0)) {};
443 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
444 // CHECK-FIXES: if (!Map.contains(0)) {};
446 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
447 // CHECK-FIXES: if (!Map.contains(0)) {};
449 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
450 // CHECK-FIXES: if (Map.contains(0)) {};
452 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
453 // CHECK-FIXES: if (Map.contains(0)) {};
455 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
456 // CHECK-FIXES: if (!Map.contains(0)) {};
458 // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use 'contains' to check for membership [readability-container-contains]
459 // CHECK-FIXES: if (!Map.contains(0)) {};