1// RUN: %check_clang_tidy %s modernize-use-override %t -- \
2// RUN: -config="{CheckOptions: {modernize-use-override.AllowOverrideAndFinal: true}}"
3
4struct Base {
5 virtual ~Base();
6 virtual void a();
7 virtual void b();
8 virtual void c();
9 virtual void d();
10 virtual void e();
11 virtual void f();
12 virtual void g();
13 virtual void h();
14 virtual void i();
15};
16
17struct Simple : public Base {
18 virtual ~Simple();
19 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
20 // CHECK-FIXES: {{^}} ~Simple() override;
21 virtual void a() override;
22 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override]
23 // CHECK-FIXES: {{^}} void a() override;
24 virtual void b() final;
25 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final' [modernize-use-override]
26 // CHECK-FIXES: {{^}} void b() final;
27 virtual void c() final override;
28 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final' [modernize-use-override]
29 // CHECK-FIXES: {{^}} void c() final override;
30 virtual void d() override final;
31 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final' [modernize-use-override]
32 // CHECK-FIXES: {{^}} void d() override final;
33 void e() final override;
34 void f() override final;
35 void g() final;
36 void h() override;
37 void i();
38 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'override' or (rarely) 'final' [modernize-use-override]
39 // CHECK-FIXES: {{^}} void i() override;
40};
41

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