1 // RUN: %check_clang_tidy %s modernize-use-override %t -- \
2 // RUN: -config="{CheckOptions: {modernize-use-override.IgnoreTemplateInstantiations: true}}"
3
4 struct Base {
5 virtual void foo();
6 };
7
8 struct Base2 {
9 virtual void foo2();
10 };
11
12 template<typename T>
13 struct Derived : T {
14 // should not warn, comes from template instance
15 virtual void foo();
16 virtual void foo2();
17 };
18
test()19 void test() {
20 Derived<Base> b;
21 Derived<Base2> b2;
22 }
23
24 template<typename T>
25 struct BaseS {
26 virtual void boo();
27 };
28
29 template<>
30 struct BaseS<int> {
31 virtual void boo2();
32 };
33
34 struct BaseU {
35 virtual void boo3();
36 };
37
38 template<typename T>
39 struct Derived2 : BaseS<T>, BaseU {
40 // should not warn, comes from template instance
41 virtual void boo();
42 virtual void boo2();
43 // should warn, comes from non-template BaseU
44 virtual void boo3();
45 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
46 // CHECK-FIXES: {{^ }}void boo3() override;
47 };
48