Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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.
5 #ifndef OVERRIDDEN_METHODS_H_
6 #define OVERRIDDEN_METHODS_H_
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 };
18 class InterimClass : public BaseClass {
19 // Should not warn about pure virtual methods.
20 virtual void SomeMethod() = 0;
21 };
23 namespace WebKit {
24 class WebKitObserver {
25 public:
26 virtual void WebKitModifiedSomething() {};
27 };
28 } // namespace WebKit
30 namespace webkit_glue {
31 class WebKitObserverImpl : WebKit::WebKitObserver {
32 public:
33 virtual void WebKitModifiedSomething() {};
34 };
35 } // namespace webkit_glue
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 };
54 #endif // OVERRIDDEN_METHODS_H_