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

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 #ifndef BASE_REFCOUNTED_H_
     6 #define BASE_REFCOUNTED_H_
     8 namespace base {
    10 template <typename T>
    11 class RefCounted {
    12  public:
    13   RefCounted() {}
    14   ~RefCounted() {}
    15 };
    17 template <typename T>
    18 class RefCountedThreadSafe {
    19  public:
    20   RefCountedThreadSafe() {}
    21   ~RefCountedThreadSafe() {}
    22 };
    24 }  // namespace base
    26 // Ignore classes whose inheritance tree ends in WebKit's RefCounted base
    27 // class. Though prone to error, this pattern is very prevalent in WebKit
    28 // code, so do not issue any warnings.
    29 namespace WebKit {
    31 template <typename T>
    32 class RefCounted {
    33  public:
    34   RefCounted() {}
    35   ~RefCounted() {}
    36 };
    38 }  // namespace WebKit
    40 // Unsafe; should error.
    41 class PublicRefCountedDtorInHeader
    42     : public base::RefCounted<PublicRefCountedDtorInHeader> {
    43  public:
    44   PublicRefCountedDtorInHeader() {}
    45   ~PublicRefCountedDtorInHeader() {}
    47  private:
    48   friend class base::RefCounted<PublicRefCountedDtorInHeader>;
    49 };
    51 // Unsafe; should error.
    52 class PublicRefCountedThreadSafeDtorInHeader
    53     : public base::RefCountedThreadSafe<
    54           PublicRefCountedThreadSafeDtorInHeader> {
    55  public:
    56   PublicRefCountedThreadSafeDtorInHeader() {}
    57   ~PublicRefCountedThreadSafeDtorInHeader() {}
    59  private:
    60   friend class base::RefCountedThreadSafe<
    61       PublicRefCountedThreadSafeDtorInHeader>;
    62 };
    64 // Safe; should not have errors.
    65 class ProtectedRefCountedDtorInHeader
    66     : public base::RefCounted<ProtectedRefCountedDtorInHeader> {
    67  public:
    68   ProtectedRefCountedDtorInHeader() {}
    70  protected:
    71   ~ProtectedRefCountedDtorInHeader() {}
    73  private:
    74   friend class base::RefCounted<ProtectedRefCountedDtorInHeader>;
    75 };
    77 // Safe; should not have errors.
    78 class PrivateRefCountedDtorInHeader
    79     : public base::RefCounted<PrivateRefCountedDtorInHeader> {
    80  public:
    81   PrivateRefCountedDtorInHeader() {}
    83  private:
    84   ~PrivateRefCountedDtorInHeader() {}
    85   friend class base::RefCounted<PrivateRefCountedDtorInHeader>;
    86 };
    88 // Unsafe; A grandchild class ends up exposing their parent and grandparent's
    89 // destructors.
    90 class DerivedProtectedToPublicInHeader
    91     : public ProtectedRefCountedDtorInHeader {
    92  public:
    93   DerivedProtectedToPublicInHeader() {}
    94   ~DerivedProtectedToPublicInHeader() {}
    95 };
    97 // Unsafe; A grandchild ends up implicitly exposing their parent and
    98 // grantparent's destructors.
    99 class ImplicitDerivedProtectedToPublicInHeader
   100     : public ProtectedRefCountedDtorInHeader {
   101  public:
   102   ImplicitDerivedProtectedToPublicInHeader() {}
   103 };
   105 // Unsafe-but-ignored; should not have errors.
   106 class WebKitPublicDtorInHeader
   107     : public WebKit::RefCounted<WebKitPublicDtorInHeader> {
   108  public:
   109   WebKitPublicDtorInHeader() {}
   110   ~WebKitPublicDtorInHeader() {}
   111 };
   113 // Unsafe-but-ignored; should not have errors.
   114 class WebKitDerivedPublicDtorInHeader
   115     : public WebKitPublicDtorInHeader {
   116  public:
   117   WebKitDerivedPublicDtorInHeader() {}
   118   ~WebKitDerivedPublicDtorInHeader() {}
   119 };
   121 #endif  // BASE_REFCOUNTED_H_

mercurial