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 SomeConstMethod() const = 0; 16 virtual void SomeMethodWithExceptionSpec() throw() = 0; 17 virtual void SomeConstMethodWithExceptionSpec() const throw(int) = 0; 18 virtual void SomeNonPureBaseMethod() {} 19 virtual void SomeMethodWithComment() = 0; 20 virtual void SomeMethodWithCommentAndBody() = 0; 21 }; 22 23 class InterimClass : public BaseClass { 24 // Should not warn about pure virtual methods. 25 virtual void SomeMethod() = 0; 26 }; 27 28 namespace WebKit { 29 class WebKitObserver { 30 public: 31 virtual void WebKitModifiedSomething() {}; 32 }; 33 } // namespace WebKit 34 35 namespace webkit_glue { 36 class WebKitObserverImpl : WebKit::WebKitObserver { 37 public: 38 virtual void WebKitModifiedSomething() {}; 39 }; 40 } // namespace webkit_glue 41 42 class DerivedClass : public InterimClass, 43 public webkit_glue::WebKitObserverImpl { 44 public: 45 // Should not warn about destructors. 46 virtual ~DerivedClass() {} 47 // Should warn. 48 virtual void SomeMethod(); 49 // Should not warn if marked as override. 50 virtual void SomeOtherMethod() override; 51 // Should warn for inline implementations. 52 virtual void SomeInlineMethod() {} 53 // Should not warn if overriding a method whose origin is WebKit. 54 virtual void WebKitModifiedSomething(); 55 // Should warn with the insertion point after the const. 56 virtual void SomeConstMethod() const {} 57 // Should warn with the insertion point after the throw spec. 58 virtual void SomeMethodWithExceptionSpec() throw() {} 59 // Should warn with the insertion point after both the const and the throw 60 // specifiers. 61 virtual void SomeConstMethodWithExceptionSpec() const throw(int) {} 62 // Should warn even if overridden method isn't pure. 63 virtual void SomeNonPureBaseMethod() {} 64 // Should warn and place correctly even when there is a comment. 65 virtual void SomeMethodWithComment(); // This is a comment. 66 // Should warn and place correctly even if there is a comment and body. 67 virtual void SomeMethodWithCommentAndBody() {} // This is a comment. 68 }; 69 70 #endif // OVERRIDDEN_METHODS_H_ 71