|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 #ifndef OVERRIDDEN_METHODS_H_ |
|
6 #define OVERRIDDEN_METHODS_H_ |
|
7 |
|
8 // Should warn about overriding of methods. |
|
9 class BaseClass { |
|
10 public: |
|
11 virtual ~BaseClass() {} |
|
12 virtual void SomeMethod() = 0; |
|
13 virtual void SomeOtherMethod() = 0; |
|
14 virtual void SomeInlineMethod() = 0; |
|
15 virtual void SomeNonPureBaseMethod() {} |
|
16 }; |
|
17 |
|
18 class InterimClass : public BaseClass { |
|
19 // Should not warn about pure virtual methods. |
|
20 virtual void SomeMethod() = 0; |
|
21 }; |
|
22 |
|
23 namespace WebKit { |
|
24 class WebKitObserver { |
|
25 public: |
|
26 virtual void WebKitModifiedSomething() {}; |
|
27 }; |
|
28 } // namespace WebKit |
|
29 |
|
30 namespace webkit_glue { |
|
31 class WebKitObserverImpl : WebKit::WebKitObserver { |
|
32 public: |
|
33 virtual void WebKitModifiedSomething() {}; |
|
34 }; |
|
35 } // namespace webkit_glue |
|
36 |
|
37 class DerivedClass : public InterimClass, |
|
38 public webkit_glue::WebKitObserverImpl { |
|
39 public: |
|
40 // Should not warn about destructors. |
|
41 virtual ~DerivedClass() {} |
|
42 // Should warn. |
|
43 virtual void SomeMethod(); |
|
44 // Should not warn if marked as override. |
|
45 virtual void SomeOtherMethod() override; |
|
46 // Should warn for inline implementations. |
|
47 virtual void SomeInlineMethod() {} |
|
48 // Should not warn if overriding a method whose origin is WebKit. |
|
49 virtual void WebKitModifiedSomething(); |
|
50 // Should warn if overridden method isn't pure. |
|
51 virtual void SomeNonPureBaseMethod() {} |
|
52 }; |
|
53 |
|
54 #endif // OVERRIDDEN_METHODS_H_ |