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