OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "overridden_methods.h" | 5 #include "overridden_methods.h" |
6 | 6 |
7 // Fill in the implementations | 7 // Fill in the implementations |
8 void DerivedClass::SomeMethod() {} | 8 void DerivedClass::SomeMethod() {} |
9 void DerivedClass::SomeOtherMethod() {} | 9 void DerivedClass::SomeOtherMethod() {} |
10 void DerivedClass::WebKitModifiedSomething() {} | 10 void DerivedClass::WebKitModifiedSomething() {} |
11 | 11 |
12 class ImplementationInterimClass : public BaseClass { | 12 class ImplementationInterimClass : public BaseClass { |
13 public: | 13 public: |
14 // Should warn about pure virtual methods. | 14 // Should not warn about pure virtual methods. |
15 virtual void SomeMethod() = 0; | 15 virtual void SomeMethod() = 0; |
16 }; | 16 }; |
17 | 17 |
18 class ImplementationDerivedClass : public ImplementationInterimClass, | 18 class ImplementationDerivedClass : public ImplementationInterimClass, |
19 public webkit_glue::WebKitObserverImpl { | 19 public webkit_glue::WebKitObserverImpl { |
20 public: | 20 public: |
21 // Should warn about destructors. | 21 // Should not warn about destructors. |
22 virtual ~ImplementationDerivedClass() {} | 22 virtual ~ImplementationDerivedClass() {} |
23 // Should warn. | 23 // Should warn. |
24 virtual void SomeMethod(); | 24 virtual void SomeMethod(); |
25 // Should not warn if marked as override. | 25 // Should not warn if marked as override. |
26 void SomeOtherMethod() override; | 26 virtual void SomeOtherMethod() override; |
27 // Should not warn for inline implementations in implementation files. | 27 // Should not warn for inline implementations in implementation files. |
28 virtual void SomeInlineMethod() {} | 28 virtual void SomeInlineMethod() {} |
29 // Should not warn if overriding a method whose origin is blink. | 29 // Should not warn if overriding a method whose origin is blink. |
30 virtual void WebKitModifiedSomething(); | 30 virtual void WebKitModifiedSomething(); |
31 // Should warn with the insertion point after the const. | 31 // Should warn with the insertion point after the const. |
32 virtual void SomeConstMethod() const {} | 32 virtual void SomeConstMethod() const {} |
33 // Should warn with the insertion point after the throw spec. | 33 // Should warn with the insertion point after the throw spec. |
34 virtual void SomeMethodWithExceptionSpec() throw() {} | 34 virtual void SomeMethodWithExceptionSpec() throw() {} |
35 // Should warn with the insertion point after both the const and the throw | 35 // Should warn with the insertion point after both the const and the throw |
36 // specifiers. | 36 // specifiers. |
37 virtual void SomeConstMethodWithExceptionSpec() const throw(int) {} | 37 virtual void SomeConstMethodWithExceptionSpec() const throw(int) {} |
38 // Should warn even if overridden method isn't pure. | 38 // Should warn even if overridden method isn't pure. |
39 virtual void SomeNonPureBaseMethod() {} | 39 virtual void SomeNonPureBaseMethod() {} |
40 // Should warn and place correctly even when there is a comment. | 40 // Should warn and place correctly even when there is a comment. |
41 virtual void SomeMethodWithComment(); // This is a comment. | 41 virtual void SomeMethodWithComment(); // This is a comment. |
42 // Should warn and place correctly even if there is a comment and body. | 42 // Should warn and place correctly even if there is a comment and body. |
43 virtual void SomeMethodWithCommentAndBody() {} // This is a comment. | 43 virtual void SomeMethodWithCommentAndBody() {} // This is a comment. |
44 }; | 44 }; |
45 | 45 |
46 int main() { | 46 int main() { |
47 DerivedClass something; | 47 DerivedClass something; |
48 ImplementationDerivedClass something_else; | 48 ImplementationDerivedClass something_else; |
49 } | 49 } |
OLD | NEW |