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 VIRTUAL_METHODS_H_
6 #define VIRTUAL_METHODS_H_
8 // Note: This is not actual windows.h but the stub file in system/windows.h
11 #define CR_BEGIN_MSG_MAP_EX(theClass) virtual int f() { return 4; }
12 #define BEGIN_SAFE_MSG_MAP_EX(theClass) virtual int g() { return 4; }
14 // Should warn about virtual method usage.
15 class VirtualMethodsInHeaders
{
17 // Don't complain about these.
18 virtual void MethodIsAbstract() = 0;
19 virtual void MethodHasNoArguments();
20 virtual void MethodHasEmptyDefaultImpl() {}
22 // But complain about this:
23 virtual bool ComplainAboutThis() { return true; }
26 CR_BEGIN_MSG_MAP_EX(Sub
)
27 BEGIN_SAFE_MSG_MAP_EX(Sub
)
30 // Complain on missing 'virtual' keyword in overrides.
31 class WarnOnMissingVirtual
: public VirtualMethodsInHeaders
{
33 void MethodHasNoArguments() override
;
36 // Don't complain about things in a 'testing' namespace.
39 } // namespace testing
41 class VirtualMethodsInHeadersTesting
: public VirtualMethodsInHeaders
{
43 // Don't complain about no virtual testing methods.
44 void MethodHasNoArguments();
47 testing::TestStruct tester_
;
50 #endif // VIRTUAL_METHODS_H_