1 | // RUN: %check_clang_tidy %s misc-confusable-identifiers %t |
2 | |
3 | int l0; |
4 | int lO; |
5 | // CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'lO' is confusable with 'l0' [misc-confusable-identifiers] |
6 | // CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here |
7 | |
8 | void no() { |
9 | int 𝐟oo; |
10 | } |
11 | |
12 | void worry() { |
13 | int foo; |
14 | } |
15 | int l1; |
16 | int ll; |
17 | // CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'll' is confusable with 'l1' [misc-confusable-identifiers] |
18 | // CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here |
19 | |
20 | bool f0(const char *q1, const char *ql) { |
21 | // CHECK-MESSAGES: :[[#@LINE-1]]:37: warning: 'ql' is confusable with 'q1' [misc-confusable-identifiers] |
22 | // CHECK-MESSAGES: :[[#@LINE-2]]:21: note: other declaration found here |
23 | return q1 < ql; |
24 | } |
25 | |
26 | // should not print anything |
27 | namespace ns { |
28 | struct Foo {}; |
29 | } // namespace ns |
30 | auto f = ns::Foo(); |
31 | |
32 | struct Test { |
33 | void f1(const char *pl); |
34 | }; |
35 | |
36 | bool f2(const char *p1, const char *ql) { |
37 | return p1 < ql; |
38 | } |
39 | |
40 | bool f3(const char *q0, const char *q1) { |
41 | return q0 < q1; |
42 | } |
43 | |
44 | template <typename i1> |
45 | struct S { |
46 | template <typename il> |
47 | void f4() {} |
48 | // CHECK-MESSAGES: :[[#@LINE-2]]:22: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers] |
49 | // CHECK-MESSAGES: :[[#@LINE-5]]:20: note: other declaration found here |
50 | }; |
51 | |
52 | template <typename i1> |
53 | void f5(int il) { |
54 | // CHECK-MESSAGES: :[[#@LINE-1]]:13: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers] |
55 | // CHECK-MESSAGES: :[[#@LINE-3]]:20: note: other declaration found here |
56 | } |
57 | |
58 | namespace f7 { |
59 | int i1; |
60 | } |
61 | |
62 | namespace f8 { |
63 | int il; // no warning, different namespace |
64 | } |
65 | |
66 | namespace f7 { |
67 | int il; |
68 | // CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers] |
69 | // CHECK-MESSAGES: :[[#@LINE-10]]:5: note: other declaration found here |
70 | } // namespace f7 |
71 | |
72 | template <typename t1, typename tl> |
73 | // CHECK-MESSAGES: :[[#@LINE-1]]:33: warning: 'tl' is confusable with 't1' [misc-confusable-identifiers] |
74 | // CHECK-MESSAGES: :[[#@LINE-2]]:20: note: other declaration found here |
75 | void f9(); |
76 | |
77 | struct Base0 { |
78 | virtual void mO0(); |
79 | |
80 | private: |
81 | void mII(); |
82 | }; |
83 | |
84 | struct Derived0 : Base0 { |
85 | void mOO(); |
86 | // CHECK-MESSAGES: :[[#@LINE-1]]:8: warning: 'mOO' is confusable with 'mO0' [misc-confusable-identifiers] |
87 | // CHECK-MESSAGES: :[[#@LINE-9]]:16: note: other declaration found here |
88 | |
89 | void mI1(); // no warning: mII is private |
90 | }; |
91 | |
92 | struct Base1 { |
93 | long mO0; |
94 | |
95 | private: |
96 | long mII; |
97 | }; |
98 | |
99 | struct Derived1 : Base1 { |
100 | long mOO; |
101 | // CHECK-MESSAGES: :[[#@LINE-1]]:8: warning: 'mOO' is confusable with 'mO0' [misc-confusable-identifiers] |
102 | // CHECK-MESSAGES: :[[#@LINE-9]]:8: note: other declaration found here |
103 | |
104 | long mI1(); // no warning: mII is private |
105 | }; |
106 | |