1 | // RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t -- |
2 | |
3 | // Test that all of the default entries in the IgnoredParameterTypeSuffixes |
4 | // option are indeed ignored. |
5 | |
6 | struct A {}; |
7 | |
8 | namespace IgnoredTypes { |
9 | using Bool = A; |
10 | using _Bool = A; |
11 | using it = A; |
12 | using It = A; |
13 | using iterator = A; |
14 | using Iterator = A; |
15 | using inputit = A; |
16 | using InputIt = A; |
17 | using forwardit = A; |
18 | using ForwardIt = A; |
19 | using bidirit = A; |
20 | using BidirIt = A; |
21 | using constiterator = A; |
22 | using const_iterator = A; |
23 | using Const_Iterator = A; |
24 | using Constiterator = A; |
25 | using ConstIterator = A; |
26 | using RandomIt = A; |
27 | using randomit = A; |
28 | using random_iterator = A; |
29 | using ReverseIt = A; |
30 | using reverse_iterator = A; |
31 | using reverse_const_iterator = A; |
32 | using ConstReverseIterator = A; |
33 | using Const_Reverse_Iterator = A; |
34 | using const_reverse_iterator = A; |
35 | using Constreverseiterator = A; |
36 | using constreverseiterator = A; |
37 | } // namespace IgnoredTypes |
38 | |
39 | // The types used here all have a suffix that is present in the default value of |
40 | // IgnoredParameterTypeSuffixes, and should therefore be ignored: |
41 | void f1(bool Foo, bool Bar) {} |
42 | void f2(IgnoredTypes::Bool Foo, IgnoredTypes::Bool Bar) {} |
43 | void f3(IgnoredTypes::_Bool Foo, IgnoredTypes::_Bool Bar) {} |
44 | void f4(IgnoredTypes::it Foo, IgnoredTypes::it Bar) {} |
45 | void f5(IgnoredTypes::It Foo, IgnoredTypes::It Bar) {} |
46 | void f6(IgnoredTypes::iterator Foo, IgnoredTypes::iterator Bar) {} |
47 | void f7(IgnoredTypes::Iterator Foo, IgnoredTypes::Iterator Bar) {} |
48 | void f8(IgnoredTypes::inputit Foo, IgnoredTypes::inputit Bar) {} |
49 | void f9(IgnoredTypes::InputIt Foo, IgnoredTypes::InputIt Bar) {} |
50 | void f10(IgnoredTypes::forwardit Foo, IgnoredTypes::forwardit Bar) {} |
51 | void f11(IgnoredTypes::ForwardIt Foo, IgnoredTypes::ForwardIt Bar) {} |
52 | void f12(IgnoredTypes::bidirit Foo, IgnoredTypes::bidirit Bar) {} |
53 | void f13(IgnoredTypes::BidirIt Foo, IgnoredTypes::BidirIt Bar) {} |
54 | void f14(IgnoredTypes::constiterator Foo, IgnoredTypes::constiterator Bar) {} |
55 | void f15(IgnoredTypes::const_iterator Foo, IgnoredTypes::const_iterator Bar) {} |
56 | void f16(IgnoredTypes::Const_Iterator Foo, IgnoredTypes::Const_Iterator Bar) {} |
57 | void f17(IgnoredTypes::Constiterator Foo, IgnoredTypes::Constiterator Bar) {} |
58 | void f18(IgnoredTypes::ConstIterator Foo, IgnoredTypes::ConstIterator Bar) {} |
59 | void f19(IgnoredTypes::RandomIt Foo, IgnoredTypes::RandomIt Bar) {} |
60 | void f20(IgnoredTypes::randomit Foo, IgnoredTypes::randomit Bar) {} |
61 | void f21(IgnoredTypes::random_iterator Foo, IgnoredTypes::random_iterator Bar) {} |
62 | void f22(IgnoredTypes::ReverseIt Foo, IgnoredTypes::ReverseIt Bar) {} |
63 | void f23(IgnoredTypes::reverse_iterator Foo, IgnoredTypes::reverse_iterator Bar) {} |
64 | void f24(IgnoredTypes::reverse_const_iterator Foo, IgnoredTypes::reverse_const_iterator Bar) {} |
65 | void f25(IgnoredTypes::ConstReverseIterator Foo, IgnoredTypes::ConstReverseIterator Bar) {} |
66 | void f26(IgnoredTypes::Const_Reverse_Iterator Foo, IgnoredTypes::Const_Reverse_Iterator Bar) {} |
67 | void f27(IgnoredTypes::const_reverse_iterator Foo, IgnoredTypes::const_reverse_iterator Bar) {} |
68 | void f28(IgnoredTypes::Constreverseiterator Foo, IgnoredTypes::Constreverseiterator Bar) {} |
69 | void f29(IgnoredTypes::constreverseiterator Foo, IgnoredTypes::constreverseiterator Bar) {} |
70 | |
71 | // This suffix of this type is not present in IgnoredParameterTypeSuffixes' |
72 | // default value, therefore, a warning _should_ be generated. |
73 | using ShouldNotBeIgnored = A; |
74 | void f30(ShouldNotBeIgnored Foo, ShouldNotBeIgnored Bar) {} |
75 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 2 adjacent parameters of 'f30' of similar type ('ShouldNotBeIgnored') are easily swapped by mistake [bugprone-easily-swappable-parameters] |
76 | // CHECK-MESSAGES: :[[@LINE-2]]:29: note: the first parameter in the range is 'Foo' |
77 | // CHECK-MESSAGES: :[[@LINE-3]]:53: note: the last parameter in the range is 'Bar' |
78 | |