1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/tools/clang/plugins/tests/virtual_methods.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +// Copyright (c) 2012 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 +#include "virtual_methods.h" 1.9 + 1.10 +// Shouldn't warn about method usage in the implementation file. 1.11 +class VirtualMethodsInImplementation { 1.12 + public: 1.13 + virtual void MethodIsAbstract() = 0; 1.14 + virtual void MethodHasNoArguments(); 1.15 + virtual void MethodHasEmptyDefaultImpl() {} 1.16 + virtual bool ComplainAboutThis() { return true; } 1.17 +}; 1.18 + 1.19 +// Stubs to fill in the abstract method 1.20 +class ConcreteVirtualMethodsInHeaders : public VirtualMethodsInHeaders { 1.21 + public: 1.22 + virtual void MethodIsAbstract() override {} 1.23 +}; 1.24 + 1.25 +class ConcreteVirtualMethodsInImplementation 1.26 + : public VirtualMethodsInImplementation { 1.27 + public: 1.28 + virtual void MethodIsAbstract() override {} 1.29 +}; 1.30 + 1.31 +// Fill in the implementations 1.32 +void VirtualMethodsInHeaders::MethodHasNoArguments() {} 1.33 +void WarnOnMissingVirtual::MethodHasNoArguments() {} 1.34 +void VirtualMethodsInImplementation::MethodHasNoArguments() {} 1.35 + 1.36 +int main() { 1.37 + ConcreteVirtualMethodsInHeaders one; 1.38 + ConcreteVirtualMethodsInImplementation two; 1.39 +}