1// RUN: %check_clang_tidy %s modernize-use-override %t -- \
2// RUN: -config="{CheckOptions: {modernize-use-override.OverrideSpelling: 'OVERRIDE',modernize-use-override.FinalSpelling: 'FINAL'}}"
3
4#define ABSTRACT = 0
5
6#define OVERRIDE override
7#define FINAL final
8#define VIRTUAL virtual
9#define NOT_VIRTUAL
10#define NOT_OVERRIDE
11
12#define MUST_USE_RESULT __attribute__((warn_unused_result))
13#define UNUSED __attribute__((unused))
14
15struct Base {
16 virtual ~Base() {}
17 virtual void a();
18 virtual void b();
19 virtual void c();
20 virtual void e() = 0;
21 virtual void f2() const = 0;
22 virtual void g() = 0;
23 virtual void j() const;
24 virtual void k() = 0;
25 virtual void l() const;
26};
27
28struct SimpleCases : public Base {
29public:
30 virtual ~SimpleCases();
31 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
32 // CHECK-FIXES: {{^}} ~SimpleCases() OVERRIDE;
33
34 void a();
35 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'OVERRIDE' or (rarely) 'FINAL' [modernize-use-override]
36 // CHECK-FIXES: {{^}} void a() OVERRIDE;
37
38 virtual void b();
39 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
40 // CHECK-FIXES: {{^}} void b() OVERRIDE;
41
42 virtual void c();
43 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
44 // CHECK-FIXES: {{^}} void c() OVERRIDE;
45
46 virtual void e() = 0;
47 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
48 // CHECK-FIXES: {{^}} void e() OVERRIDE = 0;
49
50 virtual void f2() const = 0;
51 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
52 // CHECK-FIXES: {{^}} void f2() const OVERRIDE = 0;
53
54 virtual void g() ABSTRACT;
55 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
56 // CHECK-FIXES: {{^}} void g() OVERRIDE ABSTRACT;
57
58 virtual void j() const;
59 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
60 // CHECK-FIXES: {{^}} void j() const OVERRIDE;
61
62 virtual void k() OVERRIDE;
63 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
64 // CHECK-FIXES: {{^}} void k() OVERRIDE;
65
66 virtual void l() const OVERRIDE;
67 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
68 // CHECK-FIXES: {{^}} void l() const OVERRIDE;
69};
70

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