1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/tools/clang/plugins/tests/virtual_methods.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef VIRTUAL_METHODS_H_ 1.9 +#define VIRTUAL_METHODS_H_ 1.10 + 1.11 +// Should warn about virtual method usage. 1.12 +class VirtualMethodsInHeaders { 1.13 + public: 1.14 + // Don't complain about these. 1.15 + virtual void MethodIsAbstract() = 0; 1.16 + virtual void MethodHasNoArguments(); 1.17 + virtual void MethodHasEmptyDefaultImpl() {} 1.18 + 1.19 + // But complain about this: 1.20 + virtual bool ComplainAboutThis() { return true; } 1.21 +}; 1.22 + 1.23 +// Complain on missing 'virtual' keyword in overrides. 1.24 +class WarnOnMissingVirtual : public VirtualMethodsInHeaders { 1.25 + public: 1.26 + void MethodHasNoArguments() override; 1.27 +}; 1.28 + 1.29 +// Don't complain about things in a 'testing' namespace. 1.30 +namespace testing { 1.31 +struct TestStruct {}; 1.32 +} // namespace testing 1.33 + 1.34 +class VirtualMethodsInHeadersTesting : public VirtualMethodsInHeaders { 1.35 + public: 1.36 + // Don't complain about no virtual testing methods. 1.37 + void MethodHasNoArguments(); 1.38 + private: 1.39 + testing::TestStruct tester_; 1.40 +}; 1.41 + 1.42 +#endif // VIRTUAL_METHODS_H_