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
6struct A {};
7
8namespace IgnoredTypes {
9using Bool = A;
10using _Bool = A;
11using it = A;
12using It = A;
13using iterator = A;
14using Iterator = A;
15using inputit = A;
16using InputIt = A;
17using forwardit = A;
18using ForwardIt = A;
19using bidirit = A;
20using BidirIt = A;
21using constiterator = A;
22using const_iterator = A;
23using Const_Iterator = A;
24using Constiterator = A;
25using ConstIterator = A;
26using RandomIt = A;
27using randomit = A;
28using random_iterator = A;
29using ReverseIt = A;
30using reverse_iterator = A;
31using reverse_const_iterator = A;
32using ConstReverseIterator = A;
33using Const_Reverse_Iterator = A;
34using const_reverse_iterator = A;
35using Constreverseiterator = A;
36using 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:
41void f1(bool Foo, bool Bar) {}
42void f2(IgnoredTypes::Bool Foo, IgnoredTypes::Bool Bar) {}
43void f3(IgnoredTypes::_Bool Foo, IgnoredTypes::_Bool Bar) {}
44void f4(IgnoredTypes::it Foo, IgnoredTypes::it Bar) {}
45void f5(IgnoredTypes::It Foo, IgnoredTypes::It Bar) {}
46void f6(IgnoredTypes::iterator Foo, IgnoredTypes::iterator Bar) {}
47void f7(IgnoredTypes::Iterator Foo, IgnoredTypes::Iterator Bar) {}
48void f8(IgnoredTypes::inputit Foo, IgnoredTypes::inputit Bar) {}
49void f9(IgnoredTypes::InputIt Foo, IgnoredTypes::InputIt Bar) {}
50void f10(IgnoredTypes::forwardit Foo, IgnoredTypes::forwardit Bar) {}
51void f11(IgnoredTypes::ForwardIt Foo, IgnoredTypes::ForwardIt Bar) {}
52void f12(IgnoredTypes::bidirit Foo, IgnoredTypes::bidirit Bar) {}
53void f13(IgnoredTypes::BidirIt Foo, IgnoredTypes::BidirIt Bar) {}
54void f14(IgnoredTypes::constiterator Foo, IgnoredTypes::constiterator Bar) {}
55void f15(IgnoredTypes::const_iterator Foo, IgnoredTypes::const_iterator Bar) {}
56void f16(IgnoredTypes::Const_Iterator Foo, IgnoredTypes::Const_Iterator Bar) {}
57void f17(IgnoredTypes::Constiterator Foo, IgnoredTypes::Constiterator Bar) {}
58void f18(IgnoredTypes::ConstIterator Foo, IgnoredTypes::ConstIterator Bar) {}
59void f19(IgnoredTypes::RandomIt Foo, IgnoredTypes::RandomIt Bar) {}
60void f20(IgnoredTypes::randomit Foo, IgnoredTypes::randomit Bar) {}
61void f21(IgnoredTypes::random_iterator Foo, IgnoredTypes::random_iterator Bar) {}
62void f22(IgnoredTypes::ReverseIt Foo, IgnoredTypes::ReverseIt Bar) {}
63void f23(IgnoredTypes::reverse_iterator Foo, IgnoredTypes::reverse_iterator Bar) {}
64void f24(IgnoredTypes::reverse_const_iterator Foo, IgnoredTypes::reverse_const_iterator Bar) {}
65void f25(IgnoredTypes::ConstReverseIterator Foo, IgnoredTypes::ConstReverseIterator Bar) {}
66void f26(IgnoredTypes::Const_Reverse_Iterator Foo, IgnoredTypes::Const_Reverse_Iterator Bar) {}
67void f27(IgnoredTypes::const_reverse_iterator Foo, IgnoredTypes::const_reverse_iterator Bar) {}
68void f28(IgnoredTypes::Constreverseiterator Foo, IgnoredTypes::Constreverseiterator Bar) {}
69void 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.
73using ShouldNotBeIgnored = A;
74void 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

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-ignore-default.cpp