media/webrtc/trunk/tools/clang/plugins/tests/base_refcounted.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
     3 // found in the LICENSE file.
     5 #include "base_refcounted.h"
     7 #include <cstddef>
     9 namespace {
    11 // Unsafe; should error.
    12 class AnonymousDerivedProtectedToPublicInImpl
    13     : public ProtectedRefCountedDtorInHeader {
    14  public:
    15   AnonymousDerivedProtectedToPublicInImpl() {}
    16   ~AnonymousDerivedProtectedToPublicInImpl() {}
    17 };
    19 }  // namespace
    21 // Unsafe; should error.
    22 class PublicRefCountedDtorInImpl
    23     : public base::RefCounted<PublicRefCountedDtorInImpl> {
    24  public:
    25   PublicRefCountedDtorInImpl() {}
    26   ~PublicRefCountedDtorInImpl() {}
    28  private:
    29   friend class base::RefCounted<PublicRefCountedDtorInImpl>;
    30 };
    32 class Foo {
    33  public:
    34   class BarInterface {
    35    protected:
    36     virtual ~BarInterface() {}
    37   };
    39   typedef base::RefCounted<BarInterface> RefCountedBar;
    40   typedef RefCountedBar AnotherTypedef;
    41 };
    43 class Baz {
    44  public:
    45   typedef typename Foo::AnotherTypedef MyLocalTypedef;
    46 };
    48 // Unsafe; should error.
    49 class UnsafeTypedefChainInImpl : public Baz::MyLocalTypedef {
    50  public:
    51   UnsafeTypedefChainInImpl() {}
    52   ~UnsafeTypedefChainInImpl() {}
    53 };
    55 int main() {
    56   PublicRefCountedDtorInHeader bad;
    57   PublicRefCountedDtorInImpl also_bad;
    59   ProtectedRefCountedDtorInHeader* protected_ok = NULL;
    60   PrivateRefCountedDtorInHeader* private_ok = NULL;
    62   DerivedProtectedToPublicInHeader still_bad;
    63   PublicRefCountedThreadSafeDtorInHeader another_bad_variation;
    64   AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too;
    65   ImplicitDerivedProtectedToPublicInHeader bad_yet_again;
    66   UnsafeTypedefChainInImpl and_again_this_is_bad;
    68   WebKitPublicDtorInHeader ignored;
    69   WebKitDerivedPublicDtorInHeader still_ignored;
    71   return 0;
    72 }

mercurial