1// RUN: %check_clang_tidy %s modernize-use-override %t -- \
2// RUN: -config="{CheckOptions: {modernize-use-override.IgnoreTemplateInstantiations: true}}"
3
4struct Base {
5 virtual void foo();
6};
7
8struct Base2 {
9 virtual void foo2();
10};
11
12template<typename T>
13struct Derived : T {
14 // should not warn, comes from template instance
15 virtual void foo();
16 virtual void foo2();
17};
18
19void test() {
20 Derived<Base> b;
21 Derived<Base2> b2;
22}
23
24template<typename T>
25struct BaseS {
26 virtual void boo();
27};
28
29template<>
30struct BaseS<int> {
31 virtual void boo2();
32};
33
34struct BaseU {
35 virtual void boo3();
36};
37
38template<typename T>
39struct 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

source code of clang-tools-extra/test/clang-tidy/checkers/modernize/use-override-templates.cpp