Commit 859ca039 by Jamie Madill Committed by Commit Bot

Enable "-Wshadow-field".

This warning verifies we don't give variables names that shadow fields. This is another good warning to enable that Skia requires. This CL also fixes a small number of points in code that used this bad pattern. We have to disable the warning for Glslang for now. Bug: angleproject:4046 Change-Id: I072a686e3023b60cfafa778525fe712ce1fb5a50 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1877476Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent fd58d22c
...@@ -140,6 +140,7 @@ config("extra_warnings") { ...@@ -140,6 +140,7 @@ config("extra_warnings") {
"-Wextra-semi-stmt", "-Wextra-semi-stmt",
"-Wfloat-conversion", "-Wfloat-conversion",
"-Wnon-virtual-dtor", "-Wnon-virtual-dtor",
"-Wshadow-field",
"-Wtautological-type-limit-compare", "-Wtautological-type-limit-compare",
"-Wunneeded-internal-declaration", "-Wunneeded-internal-declaration",
......
...@@ -368,4 +368,13 @@ std::ostream &FmtHex(std::ostream &os, T value) ...@@ -368,4 +368,13 @@ std::ostream &FmtHex(std::ostream &os, T value)
# define ANGLE_REENABLE_EXTRA_SEMI_WARNING # define ANGLE_REENABLE_EXTRA_SEMI_WARNING
#endif #endif
#if defined(__clang__)
# define ANGLE_DISABLE_SHADOWING_WARNING \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow-field\"")
# define ANGLE_REENABLE_SHADOWING_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_SHADOWING_WARNING
# define ANGLE_REENABLE_SHADOWING_WARNING
#endif
#endif // COMMON_DEBUG_H_ #endif // COMMON_DEBUG_H_
...@@ -577,11 +577,11 @@ void TIntermTraverser::queueReplacementWithParent(TIntermNode *parent, ...@@ -577,11 +577,11 @@ void TIntermTraverser::queueReplacementWithParent(TIntermNode *parent,
mReplacements.push_back(NodeUpdateEntry(parent, original, replacement, originalBecomesChild)); mReplacements.push_back(NodeUpdateEntry(parent, original, replacement, originalBecomesChild));
} }
TLValueTrackingTraverser::TLValueTrackingTraverser(bool preVisit, TLValueTrackingTraverser::TLValueTrackingTraverser(bool preVisitIn,
bool inVisit, bool inVisitIn,
bool postVisit, bool postVisitIn,
TSymbolTable *symbolTable) TSymbolTable *symbolTable)
: TIntermTraverser(preVisit, inVisit, postVisit, symbolTable), : TIntermTraverser(preVisitIn, inVisitIn, postVisitIn, symbolTable),
mOperatorRequiresLValue(false), mOperatorRequiresLValue(false),
mInFunctionCallOutParameter(false) mInFunctionCallOutParameter(false)
{ {
......
...@@ -35,9 +35,9 @@ class TIntermTraverser : angle::NonCopyable ...@@ -35,9 +35,9 @@ class TIntermTraverser : angle::NonCopyable
{ {
public: public:
POOL_ALLOCATOR_NEW_DELETE POOL_ALLOCATOR_NEW_DELETE
TIntermTraverser(bool preVisit, TIntermTraverser(bool preVisitIn,
bool inVisit, bool inVisitIn,
bool postVisit, bool postVisitIn,
TSymbolTable *symbolTable = nullptr); TSymbolTable *symbolTable = nullptr);
virtual ~TIntermTraverser(); virtual ~TIntermTraverser();
......
...@@ -45,10 +45,7 @@ class ReplaceShadowingVariablesTraverser : public TIntermTraverser ...@@ -45,10 +45,7 @@ class ReplaceShadowingVariablesTraverser : public TIntermTraverser
{ {
public: public:
ReplaceShadowingVariablesTraverser(TSymbolTable *symbolTable) ReplaceShadowingVariablesTraverser(TSymbolTable *symbolTable)
: TIntermTraverser(true, true, true), : TIntermTraverser(true, true, true, symbolTable), mParameterNames{}, mFunctionBody(nullptr)
mSymbolTable(symbolTable),
mParameterNames{},
mFunctionBody(nullptr)
{} {}
bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override
...@@ -121,7 +118,6 @@ class ReplaceShadowingVariablesTraverser : public TIntermTraverser ...@@ -121,7 +118,6 @@ class ReplaceShadowingVariablesTraverser : public TIntermTraverser
} }
private: private:
TSymbolTable *mSymbolTable;
std::unordered_set<std::string> mParameterNames; std::unordered_set<std::string> mParameterNames;
TIntermBlock *mFunctionBody; TIntermBlock *mFunctionBody;
std::vector<DeferredReplacementBlock> mReplacements; std::vector<DeferredReplacementBlock> mReplacements;
......
...@@ -244,8 +244,8 @@ struct SamplerBinding ...@@ -244,8 +244,8 @@ struct SamplerBinding
// elements specified by 'arrayIndex' can set to be enabled. // elements specified by 'arrayIndex' can set to be enabled.
struct TransformFeedbackVarying : public sh::ShaderVariable struct TransformFeedbackVarying : public sh::ShaderVariable
{ {
TransformFeedbackVarying(const sh::ShaderVariable &varyingIn, GLuint index) TransformFeedbackVarying(const sh::ShaderVariable &varyingIn, GLuint arrayIndexIn)
: sh::ShaderVariable(varyingIn), arrayIndex(index) : sh::ShaderVariable(varyingIn), arrayIndex(arrayIndexIn)
{ {
ASSERT(!isArrayOfArrays()); ASSERT(!isArrayOfArrays());
} }
......
...@@ -873,7 +873,7 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask ...@@ -873,7 +873,7 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask
{ {
public: public:
LoadBinaryTask(ProgramD3D *program, gl::BinaryInputStream *stream, gl::InfoLog &infoLog) LoadBinaryTask(ProgramD3D *program, gl::BinaryInputStream *stream, gl::InfoLog &infoLog)
: ProgramD3D::GetExecutableTask(program), mProgram(program), mInfoLog(infoLog) : ProgramD3D::GetExecutableTask(program)
{ {
ASSERT(mProgram); ASSERT(mProgram);
ASSERT(stream); ASSERT(stream);
...@@ -901,9 +901,6 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask ...@@ -901,9 +901,6 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask
} }
private: private:
ProgramD3D *mProgram;
gl::InfoLog &mInfoLog;
bool mDataCopySucceeded; bool mDataCopySucceeded;
angle::MemoryBuffer mStreamData; angle::MemoryBuffer mStreamData;
}; };
...@@ -1903,7 +1900,7 @@ std::unique_ptr<LinkEvent> ProgramD3D::compileProgramExecutables(const gl::Conte ...@@ -1903,7 +1900,7 @@ std::unique_ptr<LinkEvent> ProgramD3D::compileProgramExecutables(const gl::Conte
auto pixelTask = std::make_shared<GetPixelExecutableTask>(this); auto pixelTask = std::make_shared<GetPixelExecutableTask>(this);
auto geometryTask = std::make_shared<GetGeometryExecutableTask>(this, context->getState()); auto geometryTask = std::make_shared<GetGeometryExecutableTask>(this, context->getState());
bool useGS = usesGeometryShader(context->getState(), gl::PrimitiveMode::Points); bool useGS = usesGeometryShader(context->getState(), gl::PrimitiveMode::Points);
gl::Shader *vertexShader = mState.getAttachedShader(gl::ShaderType::Vertex); gl::Shader *vertexShader = mState.getAttachedShader(gl::ShaderType::Vertex);
gl::Shader *fragmentShader = mState.getAttachedShader(gl::ShaderType::Fragment); gl::Shader *fragmentShader = mState.getAttachedShader(gl::ShaderType::Fragment);
const ShaderD3D *vertexShaderD3D = vertexShader ? GetImplAs<ShaderD3D>(vertexShader) : nullptr; const ShaderD3D *vertexShaderD3D = vertexShader ? GetImplAs<ShaderD3D>(vertexShader) : nullptr;
const ShaderD3D *fragmentShaderD3D = const ShaderD3D *fragmentShaderD3D =
......
...@@ -11,13 +11,13 @@ namespace rx ...@@ -11,13 +11,13 @@ namespace rx
ContextEGL::ContextEGL(const gl::State &state, ContextEGL::ContextEGL(const gl::State &state,
gl::ErrorSet *errorSet, gl::ErrorSet *errorSet,
const std::shared_ptr<RendererEGL> &renderer) const std::shared_ptr<RendererEGL> &renderer)
: ContextGL(state, errorSet, renderer), mRenderer(renderer) : ContextGL(state, errorSet, renderer), mRendererEGL(renderer)
{} {}
ContextEGL::~ContextEGL() {} ContextEGL::~ContextEGL() {}
EGLContext ContextEGL::getContext() const EGLContext ContextEGL::getContext() const
{ {
return mRenderer->getContext(); return mRendererEGL->getContext();
} }
} // namespace rx } // namespace rx
...@@ -25,7 +25,7 @@ class ContextEGL : public ContextGL ...@@ -25,7 +25,7 @@ class ContextEGL : public ContextGL
EGLContext getContext() const; EGLContext getContext() const;
private: private:
std::shared_ptr<RendererEGL> mRenderer; std::shared_ptr<RendererEGL> mRendererEGL;
}; };
} // namespace rx } // namespace rx
......
...@@ -11,13 +11,13 @@ namespace rx ...@@ -11,13 +11,13 @@ namespace rx
ContextWGL::ContextWGL(const gl::State &state, ContextWGL::ContextWGL(const gl::State &state,
gl::ErrorSet *errorSet, gl::ErrorSet *errorSet,
const std::shared_ptr<RendererWGL> &renderer) const std::shared_ptr<RendererWGL> &renderer)
: ContextGL(state, errorSet, renderer), mRenderer(renderer) : ContextGL(state, errorSet, renderer), mRendererWGL(renderer)
{} {}
ContextWGL::~ContextWGL() {} ContextWGL::~ContextWGL() {}
HGLRC ContextWGL::getContext() const HGLRC ContextWGL::getContext() const
{ {
return mRenderer->getContext(); return mRendererWGL->getContext();
} }
} // namespace rx } // namespace rx
...@@ -25,7 +25,7 @@ class ContextWGL : public ContextGL ...@@ -25,7 +25,7 @@ class ContextWGL : public ContextGL
HGLRC getContext() const; HGLRC getContext() const;
private: private:
std::shared_ptr<RendererWGL> mRenderer; std::shared_ptr<RendererWGL> mRendererWGL;
}; };
} // namespace rx } // namespace rx
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// glslang has issues with some specific warnings. // glslang has issues with some specific warnings.
ANGLE_DISABLE_EXTRA_SEMI_WARNING ANGLE_DISABLE_EXTRA_SEMI_WARNING
ANGLE_DISABLE_SHADOWING_WARNING
// glslang's version of ShaderLang.h, not to be confused with ANGLE's. // glslang's version of ShaderLang.h, not to be confused with ANGLE's.
#include <glslang/Public/ShaderLang.h> #include <glslang/Public/ShaderLang.h>
...@@ -18,6 +19,7 @@ ANGLE_DISABLE_EXTRA_SEMI_WARNING ...@@ -18,6 +19,7 @@ ANGLE_DISABLE_EXTRA_SEMI_WARNING
#include <SPIRV/GlslangToSpv.h> #include <SPIRV/GlslangToSpv.h>
#include <StandAlone/ResourceLimits.h> #include <StandAlone/ResourceLimits.h>
ANGLE_REENABLE_SHADOWING_WARNING
ANGLE_REENABLE_EXTRA_SEMI_WARNING ANGLE_REENABLE_EXTRA_SEMI_WARNING
#include <array> #include <array>
......
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