Commit aa7203ef by Frank Henigman Committed by Commit Bot

Inherit privately from angle::NonCopyable.

Make all inheritance from angle::NonCopyable private so the compiler complains about this (admittedly unlikely) code: class Foo: angle::NonCopyable { virtual ~Foo() { ... } }; angle::NonCopyable *p = new Foo; delete p; In the above code ~Foo() is not called, only ~NonCopyable(), because the latter is not virtual. Making it virtual would add overhead to all derived classes which don't already have a virtual method. Also tighten access in NonCopyable, because we can. BUG=angleproject:2026 Change-Id: Id0dc4d959cfb7bb82cf49382118129abb1d3a4f0 Reviewed-on: https://chromium-review.googlesource.com/495352Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
parent 6a1d2f93
...@@ -29,10 +29,11 @@ using Microsoft::WRL::ComPtr; ...@@ -29,10 +29,11 @@ using Microsoft::WRL::ComPtr;
class NonCopyable class NonCopyable
{ {
public: protected:
NonCopyable() = default; NonCopyable() = default;
~NonCopyable() = default; ~NonCopyable() = default;
protected:
private:
NonCopyable(const NonCopyable&) = delete; NonCopyable(const NonCopyable&) = delete;
void operator=(const NonCopyable&) = delete; void operator=(const NonCopyable&) = delete;
}; };
......
...@@ -19,7 +19,7 @@ class DirectiveHandler; ...@@ -19,7 +19,7 @@ class DirectiveHandler;
struct PreprocessorImpl; struct PreprocessorImpl;
struct Token; struct Token;
struct PreprocessorSettings : angle::NonCopyable struct PreprocessorSettings : private angle::NonCopyable
{ {
PreprocessorSettings() : maxMacroExpansionDepth(1000) {} PreprocessorSettings() : maxMacroExpansionDepth(1000) {}
int maxMacroExpansionDepth; int maxMacroExpansionDepth;
......
...@@ -25,7 +25,7 @@ namespace angle ...@@ -25,7 +25,7 @@ namespace angle
namespace namespace
{ {
struct LibPCI : angle::NonCopyable struct LibPCI : private angle::NonCopyable
{ {
LibPCI() LibPCI()
{ {
......
...@@ -34,7 +34,7 @@ static constexpr Version ES_3_1 = Version(3, 1); ...@@ -34,7 +34,7 @@ static constexpr Version ES_3_1 = Version(3, 1);
using ContextID = uintptr_t; using ContextID = uintptr_t;
class ContextState final : public angle::NonCopyable class ContextState final : angle::NonCopyable
{ {
public: public:
ContextState(ContextID context, ContextState(ContextID context,
......
...@@ -41,7 +41,7 @@ class Stream; ...@@ -41,7 +41,7 @@ class Stream;
using SurfaceSet = std::set<Surface *>; using SurfaceSet = std::set<Surface *>;
struct DisplayState final : angle::NonCopyable struct DisplayState final : private angle::NonCopyable
{ {
SurfaceSet surfaceSet; SurfaceSet surfaceSet;
}; };
......
...@@ -57,7 +57,7 @@ class ImageSibling : public RefCountObject, public gl::FramebufferAttachmentObje ...@@ -57,7 +57,7 @@ class ImageSibling : public RefCountObject, public gl::FramebufferAttachmentObje
BindingPointer<Image> mTargetOf; BindingPointer<Image> mTargetOf;
}; };
struct ImageState : angle::NonCopyable struct ImageState : private angle::NonCopyable
{ {
ImageState(EGLenum target, ImageSibling *buffer, const AttributeMap &attribs); ImageState(EGLenum target, ImageSibling *buffer, const AttributeMap &attribs);
......
...@@ -37,7 +37,7 @@ class AttributeMap; ...@@ -37,7 +37,7 @@ class AttributeMap;
class Display; class Display;
struct Config; struct Config;
struct SurfaceState final : angle::NonCopyable struct SurfaceState final : private angle::NonCopyable
{ {
SurfaceState(const egl::Config *configIn); SurfaceState(const egl::Config *configIn);
......
...@@ -82,7 +82,7 @@ struct SwizzleState final ...@@ -82,7 +82,7 @@ struct SwizzleState final
}; };
// State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec. // State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec.
struct TextureState final : public angle::NonCopyable struct TextureState final : private angle::NonCopyable
{ {
TextureState(GLenum target); TextureState(GLenum target);
......
...@@ -27,7 +27,7 @@ struct Caps; ...@@ -27,7 +27,7 @@ struct Caps;
class Context; class Context;
class Program; class Program;
class TransformFeedbackState final : public angle::NonCopyable class TransformFeedbackState final : angle::NonCopyable
{ {
public: public:
TransformFeedbackState(size_t maxIndexedBuffers); TransformFeedbackState(size_t maxIndexedBuffers);
......
...@@ -31,7 +31,7 @@ namespace gl ...@@ -31,7 +31,7 @@ namespace gl
{ {
class Buffer; class Buffer;
class VertexArrayState final : public angle::NonCopyable class VertexArrayState final : angle::NonCopyable
{ {
public: public:
VertexArrayState(size_t maxAttribs, size_t maxBindings); VertexArrayState(size_t maxAttribs, size_t maxBindings);
......
...@@ -18,7 +18,7 @@ class VertexArray; ...@@ -18,7 +18,7 @@ class VertexArray;
// //
// Implementation of Generic Vertex Attribute Bindings for ES3.1 // Implementation of Generic Vertex Attribute Bindings for ES3.1
// //
struct VertexBinding final : angle::NonCopyable struct VertexBinding final : private angle::NonCopyable
{ {
VertexBinding(); VertexBinding();
explicit VertexBinding(VertexBinding &&binding); explicit VertexBinding(VertexBinding &&binding);
...@@ -34,7 +34,7 @@ struct VertexBinding final : angle::NonCopyable ...@@ -34,7 +34,7 @@ struct VertexBinding final : angle::NonCopyable
// //
// Implementation of Generic Vertex Attributes for ES3.1 // Implementation of Generic Vertex Attributes for ES3.1
// //
struct VertexAttribute final : angle::NonCopyable struct VertexAttribute final : private angle::NonCopyable
{ {
explicit VertexAttribute(GLuint bindingIndex); explicit VertexAttribute(GLuint bindingIndex);
explicit VertexAttribute(VertexAttribute &&attrib); explicit VertexAttribute(VertexAttribute &&attrib);
......
...@@ -289,7 +289,7 @@ enum VertexFormatType ...@@ -289,7 +289,7 @@ enum VertexFormatType
typedef std::vector<VertexFormatType> InputLayout; typedef std::vector<VertexFormatType> InputLayout;
struct VertexFormat : angle::NonCopyable struct VertexFormat : private angle::NonCopyable
{ {
VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn); VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace angle namespace angle
{ {
struct Format final : angle::NonCopyable struct Format final : private angle::NonCopyable
{ {
enum class ID; enum class ID;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
namespace rx namespace rx
{ {
class SamplerImpl : public angle::NonCopyable class SamplerImpl : angle::NonCopyable
{ {
public: public:
SamplerImpl() {} SamplerImpl() {}
......
...@@ -55,7 +55,7 @@ struct PixelShaderOutputVariable ...@@ -55,7 +55,7 @@ struct PixelShaderOutputVariable
size_t outputIndex = 0; size_t outputIndex = 0;
}; };
struct BuiltinVarying final : angle::NonCopyable struct BuiltinVarying final : private angle::NonCopyable
{ {
BuiltinVarying(); BuiltinVarying();
......
...@@ -32,7 +32,7 @@ class ShaderExecutableD3D; ...@@ -32,7 +32,7 @@ class ShaderExecutableD3D;
#endif #endif
// Helper struct representing a single shader uniform // Helper struct representing a single shader uniform
struct D3DUniform : angle::NonCopyable struct D3DUniform : private angle::NonCopyable
{ {
D3DUniform(GLenum typeIn, D3DUniform(GLenum typeIn,
const std::string &nameIn, const std::string &nameIn,
......
...@@ -42,7 +42,7 @@ class Clear11 : angle::NonCopyable ...@@ -42,7 +42,7 @@ class Clear11 : angle::NonCopyable
const gl::FramebufferState &fboData); const gl::FramebufferState &fboData);
private: private:
class ShaderManager final : public angle::NonCopyable class ShaderManager final : angle::NonCopyable
{ {
public: public:
ShaderManager(); ShaderManager();
......
...@@ -36,7 +36,7 @@ class Query11 : public QueryImpl ...@@ -36,7 +36,7 @@ class Query11 : public QueryImpl
gl::Error resume(); gl::Error resume();
private: private:
struct QueryState final : public angle::NonCopyable struct QueryState final : private angle::NonCopyable
{ {
QueryState(); QueryState();
~QueryState(); ~QueryState();
......
...@@ -41,7 +41,7 @@ struct DXGIFormatSize ...@@ -41,7 +41,7 @@ struct DXGIFormatSize
}; };
const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format); const DXGIFormatSize &GetDXGIFormatSizeInfo(DXGI_FORMAT format);
struct VertexFormat : angle::NonCopyable struct VertexFormat : private angle::NonCopyable
{ {
constexpr VertexFormat(); constexpr VertexFormat();
constexpr VertexFormat(VertexConversionType conversionType, constexpr VertexFormat(VertexConversionType conversionType,
......
...@@ -223,7 +223,7 @@ ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&byteCode)[N], co ...@@ -223,7 +223,7 @@ ID3D11PixelShader *CompilePS(ID3D11Device *device, const BYTE (&byteCode)[N], co
} }
template <typename ResourceType> template <typename ResourceType>
class LazyResource : public angle::NonCopyable class LazyResource : angle::NonCopyable
{ {
public: public:
LazyResource() : mResource(nullptr), mAssociatedDevice(nullptr) {} LazyResource() : mResource(nullptr), mAssociatedDevice(nullptr) {}
......
...@@ -30,7 +30,7 @@ namespace d3d11 ...@@ -30,7 +30,7 @@ namespace d3d11
// on device capabilities. // on device capabilities.
// This structure allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and // This structure allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format. // DSVs given a GL internal format.
struct Format final : angle::NonCopyable struct Format final : private angle::NonCopyable
{ {
constexpr Format(); constexpr Format();
constexpr Format(GLenum internalFormat, constexpr Format(GLenum internalFormat,
......
...@@ -53,7 +53,7 @@ gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program) ...@@ -53,7 +53,7 @@ gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program)
return gl::NoError(); return gl::NoError();
} }
class ScopedGLState : public angle::NonCopyable class ScopedGLState : angle::NonCopyable
{ {
public: public:
enum enum
......
...@@ -28,7 +28,7 @@ class StateManagerGL; ...@@ -28,7 +28,7 @@ class StateManagerGL;
class TextureGL; class TextureGL;
struct WorkaroundsGL; struct WorkaroundsGL;
class BlitGL : public angle::NonCopyable class BlitGL : angle::NonCopyable
{ {
public: public:
BlitGL(const FunctionsGL *functions, BlitGL(const FunctionsGL *functions,
......
...@@ -20,7 +20,7 @@ namespace rx ...@@ -20,7 +20,7 @@ namespace rx
namespace vk namespace vk
{ {
struct Format final : angle::NonCopyable struct Format final : private angle::NonCopyable
{ {
constexpr Format(GLenum internalFormat, constexpr Format(GLenum internalFormat,
angle::Format::ID formatID, angle::Format::ID formatID,
......
...@@ -69,7 +69,7 @@ class VertexAttributeTest : public ANGLETest ...@@ -69,7 +69,7 @@ class VertexAttributeTest : public ANGLETest
IMMEDIATE, IMMEDIATE,
}; };
struct TestData final : angle::NonCopyable struct TestData final : private angle::NonCopyable
{ {
TestData(GLenum typeIn, TestData(GLenum typeIn,
GLboolean normalizedIn, GLboolean normalizedIn,
......
...@@ -18,7 +18,7 @@ using namespace testing; ...@@ -18,7 +18,7 @@ using namespace testing;
namespace namespace
{ {
// Only applies to D3D11 // Only applies to D3D11
struct Captures final : angle::NonCopyable struct Captures final : private angle::NonCopyable
{ {
Timer *timer = CreateTimer(); Timer *timer = CreateTimer();
size_t loadDLLsMS = 0; size_t loadDLLsMS = 0;
......
...@@ -187,7 +187,7 @@ class EGLWindow; ...@@ -187,7 +187,7 @@ class EGLWindow;
class OSWindow; class OSWindow;
class ANGLETest; class ANGLETest;
struct TestPlatformContext final : angle::NonCopyable struct TestPlatformContext final : private angle::NonCopyable
{ {
bool ignoreMessages = false; bool ignoreMessages = false;
ANGLETest *currentTest = nullptr; ANGLETest *currentTest = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment