| Index: tools/clang/plugins/tests/base_refcounted.h
|
| diff --git a/tools/clang/plugins/tests/base_refcounted.h b/tools/clang/plugins/tests/base_refcounted.h
|
| index 1e532159972c56e65160f20e9a0bb353a06d2838..840009da3f426c7f910dd5b6980be156994d76bd 100644
|
| --- a/tools/clang/plugins/tests/base_refcounted.h
|
| +++ b/tools/clang/plugins/tests/base_refcounted.h
|
| @@ -11,6 +11,7 @@ template <typename T>
|
| class RefCounted {
|
| public:
|
| RefCounted() {}
|
| + protected:
|
| ~RefCounted() {}
|
| };
|
|
|
| @@ -18,6 +19,7 @@ template <typename T>
|
| class RefCountedThreadSafe {
|
| public:
|
| RefCountedThreadSafe() {}
|
| + protected:
|
| ~RefCountedThreadSafe() {}
|
| };
|
|
|
| @@ -118,4 +120,90 @@ class WebKitDerivedPublicDtorInHeader
|
| ~WebKitDerivedPublicDtorInHeader() {}
|
| };
|
|
|
| +class APublicInterface {
|
| + public:
|
| + virtual ~APublicInterface() {}
|
| + virtual void DoFoo() = 0;
|
| +};
|
| +
|
| +// Unsafe. "ImplementsAPublicInterface* foo" can be deleted via
|
| +// "delete (APublicInterface*)foo;".
|
| +class ImplementsAPublicInterface
|
| + : public APublicInterface,
|
| + public base::RefCounted<ImplementsAPublicInterface> {
|
| + public:
|
| + virtual void DoFoo() override {}
|
| +
|
| + protected:
|
| + virtual ~ImplementsAPublicInterface() {}
|
| +
|
| + private:
|
| + friend class base::RefCounted<ImplementsAPublicInterface>;
|
| +};
|
| +
|
| +class AnImplicitInterface {
|
| + public:
|
| + virtual void DoBar() {}
|
| +};
|
| +
|
| +// Unsafe.
|
| +class ImplementsAnImplicitInterface
|
| + : public AnImplicitInterface,
|
| + public base::RefCounted<ImplementsAnImplicitInterface> {
|
| + public:
|
| + virtual void DoBar() override {}
|
| +
|
| + private:
|
| + friend class base::RefCounted<ImplementsAnImplicitInterface>;
|
| + ~ImplementsAnImplicitInterface() {}
|
| +};
|
| +
|
| +// Safe. Private inheritance does not expose the base destructor.
|
| +class PrivatelyImplementsAPublicInterface
|
| + : private APublicInterface,
|
| + public base::RefCounted<PrivatelyImplementsAPublicInterface> {
|
| + public:
|
| + virtual void DoFoo() override {}
|
| +
|
| + private:
|
| + friend class base::RefCounted<PrivatelyImplementsAPublicInterface>;
|
| + virtual ~PrivatelyImplementsAPublicInterface() {}
|
| +};
|
| +
|
| +// Unsafe.
|
| +class BaseInterface {
|
| + public:
|
| + virtual ~BaseInterface() {}
|
| + virtual void DoFoo() {}
|
| +};
|
| +class DerivedInterface : public BaseInterface {
|
| + protected:
|
| + virtual ~DerivedInterface() {}
|
| +};
|
| +class SomeOtherInterface {
|
| + public:
|
| + virtual ~SomeOtherInterface() {}
|
| + virtual void DoBar() {}
|
| +};
|
| +class RefcountedType : public base::RefCounted<RefcountedType> {
|
| + protected:
|
| + ~RefcountedType() {}
|
| + private:
|
| + friend class base::RefCounted<RefcountedType>;
|
| +};
|
| +class UnsafeInheritanceChain
|
| + : public DerivedInterface,
|
| + public SomeOtherInterface,
|
| + public RefcountedType {
|
| + public:
|
| + // DerivedInterface
|
| + virtual void DoFoo() override {}
|
| +
|
| + // SomeOtherInterface
|
| + virtual void DoBar() override {}
|
| +
|
| + protected:
|
| + virtual ~UnsafeInheritanceChain() {}
|
| +};
|
| +
|
| #endif // BASE_REFCOUNTED_H_
|
|
|