You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/misc-virtual-near-miss.cpp
+44
Original file line number
Diff line number
Diff line change
@@ -16,22 +16,58 @@ struct Derived : Base {
16
16
// overriden by this class.
17
17
virtualvoidfunk();
18
18
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
19
+
// CHECK-FIXES: virtual void func();
19
20
20
21
voidfunc2();
21
22
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
23
+
// CHECK-FIXES: void func();
22
24
23
25
voidfunc22(); // Should not warn.
24
26
25
27
voidgunk(); // Should not warn: gunk is override.
26
28
27
29
voidfun();
28
30
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
31
+
// CHECK-FIXES: void func();
29
32
30
33
Derived &operator==(const Base &); // Should not warn: operators are ignored.
31
34
32
35
virtual NoDefinedClass2 *f1(); // Should not crash: non-defined class return type is ignored.
33
36
};
34
37
38
+
template <typename T>
39
+
structTBase {
40
+
virtualvoidtfunc(T t);
41
+
};
42
+
43
+
template <typename T>
44
+
structTDerived : TBase<T> {
45
+
virtualvoidtfunk(T t);
46
+
// Should not apply fix for template.
47
+
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: method 'TDerived<double>::tfunk' has {{.*}} 'TBase<double>::tfunc'
48
+
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: method 'TDerived<int>::tfunk' has {{.*}} 'TBase<int>::tfunc'
49
+
// CHECK-FIXES: virtual void tfunk(T t);
50
+
};
51
+
52
+
TDerived<int> T1;
53
+
TDerived<double> T2;
54
+
55
+
// Should not fix macro definition
56
+
#defineMACRO1voidfuncM()
57
+
// CHECK-FIXES: #define MACRO1 void funcM()
58
+
#defineMACRO2(m) voidm()
59
+
// CHECK-FIXES: #define MACRO2(m) void m()
60
+
61
+
struct DerivedMacro : Base {
62
+
MACRO1;
63
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::funcM' has {{.*}} 'Base::func'
64
+
// CHECK-FIXES: MACRO1;
65
+
66
+
MACRO2(func3);
67
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::func3' has {{.*}} 'Base::func'
0 commit comments