michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef VIRTUAL_METHODS_H_ michael@0: #define VIRTUAL_METHODS_H_ michael@0: michael@0: // Should warn about virtual method usage. michael@0: class VirtualMethodsInHeaders { michael@0: public: michael@0: // Don't complain about these. michael@0: virtual void MethodIsAbstract() = 0; michael@0: virtual void MethodHasNoArguments(); michael@0: virtual void MethodHasEmptyDefaultImpl() {} michael@0: michael@0: // But complain about this: michael@0: virtual bool ComplainAboutThis() { return true; } michael@0: }; michael@0: michael@0: // Complain on missing 'virtual' keyword in overrides. michael@0: class WarnOnMissingVirtual : public VirtualMethodsInHeaders { michael@0: public: michael@0: void MethodHasNoArguments() override; michael@0: }; michael@0: michael@0: // Don't complain about things in a 'testing' namespace. michael@0: namespace testing { michael@0: struct TestStruct {}; michael@0: } // namespace testing michael@0: michael@0: class VirtualMethodsInHeadersTesting : public VirtualMethodsInHeaders { michael@0: public: michael@0: // Don't complain about no virtual testing methods. michael@0: void MethodHasNoArguments(); michael@0: private: michael@0: testing::TestStruct tester_; michael@0: }; michael@0: michael@0: #endif // VIRTUAL_METHODS_H_