Commit cb87d78c by Jamie Madill Committed by Angle LUCI CQ

Enable -Wshadow with Clang.

Also fixes a few instances of variable shadowing in the code. Bug: angleproject:6148 Change-Id: Ic51d722a3f953f246f51af6d74abb302f832cf44 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3014875Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 54ade715
......@@ -198,6 +198,7 @@ config("extra_warnings") {
"-Wnon-virtual-dtor",
"-Wredundant-parens",
"-Wreturn-std-move",
"-Wshadow",
"-Wshadow-field",
"-Wtautological-type-limit-compare",
"-Wundefined-reinterpret-cast",
......
......@@ -404,9 +404,9 @@ bool TIntermAggregate::replaceChildNode(TIntermNode *original, TIntermNode *repl
TIntermBlock::TIntermBlock(const TIntermBlock &node)
{
for (TIntermNode *node : node.mStatements)
for (TIntermNode *intermNode : node.mStatements)
{
mStatements.push_back(node->deepCopy());
mStatements.push_back(intermNode->deepCopy());
}
ASSERT(!node.mIsTreeRoot);
......@@ -506,9 +506,9 @@ bool TIntermDeclaration::replaceChildNode(TIntermNode *original, TIntermNode *re
TIntermDeclaration::TIntermDeclaration(const TIntermDeclaration &node)
{
for (TIntermNode *node : node.mDeclarators)
for (TIntermNode *intermNode : node.mDeclarators)
{
mDeclarators.push_back(node->deepCopy());
mDeclarators.push_back(intermNode->deepCopy());
}
}
......
......@@ -2214,9 +2214,9 @@ bool GenMetalTraverser::visitDeclaration(Visit, TIntermDeclaration *declNode)
else if (TIntermBinary *initNode = node.getAsBinaryNode())
{
ASSERT(initNode->getOp() == TOperator::EOpInitialize);
TIntermSymbol *symbolNode = initNode->getLeft()->getAsSymbolNode();
TIntermTyped *valueNode = initNode->getRight()->getAsTyped();
ASSERT(symbolNode && valueNode);
TIntermSymbol *leftSymbolNode = initNode->getLeft()->getAsSymbolNode();
TIntermTyped *valueNode = initNode->getRight()->getAsTyped();
ASSERT(leftSymbolNode && valueNode);
if (getRootNode() == getParentBlock())
{
......@@ -2228,7 +2228,7 @@ bool GenMetalTraverser::visitDeclaration(Visit, TIntermDeclaration *declNode)
mOut << "constant ";
}
const TVariable &var = symbolNode->variable();
const TVariable &var = leftSymbolNode->variable();
const Name varName(var);
if (ExpressionContainsName(varName, *valueNode))
......
......@@ -357,7 +357,7 @@ class ConvertStructState : angle::NonCopyable
bool recurse(const TStructure &structure,
ModifiedStructMachinery &outMachinery,
const bool isUBO)
const bool isUBORecurse)
{
const ModifiedStructMachinery *m = outMachineries.find(structure);
if (m == nullptr)
......@@ -367,7 +367,7 @@ class ConvertStructState : angle::NonCopyable
reflection->addOriginalName(structure.uniqueId().get(), structure.name().data());
const Name name = idGen.createNewName(structure.name().data());
if (!TryCreateModifiedStruct(mCompiler, symbolEnv, idGen, config, structure, name,
outMachineries, isUBO, true))
outMachineries, isUBORecurse, true))
{
return false;
}
......
......@@ -217,9 +217,9 @@ bool GetAsDeclaredStructure(SymbolEnv &symbolEnv,
if (TIntermDeclaration *declNode = node.getAsDeclarationNode())
{
ASSERT(declNode->getChildCount() == 1);
TIntermNode &node = *declNode->getChildNode(0);
TIntermNode &childNode = *declNode->getChildNode(0);
if (TIntermSymbol *symbolNode = node.getAsSymbolNode())
if (TIntermSymbol *symbolNode = childNode.getAsSymbolNode())
{
const TVariable &var = symbolNode->variable();
const TType &type = var.getType();
......@@ -306,11 +306,11 @@ bool sh::ToposortStructs(TCompiler &compiler,
root.traverse(&finder);
ppc.hasStructEq = !finder.mUsedStructs.empty();
DeclaredStructure declaredStruct;
std::vector<DeclaredStructure> declaredStructs;
std::vector<TIntermNode *> nonStructStmtNodes;
{
DeclaredStructure declaredStruct;
const size_t stmtCount = root.getChildCount();
for (size_t i = 0; i < stmtCount; ++i)
{
......
......@@ -653,9 +653,9 @@ void TextureState::setImageDesc(TextureTarget target, size_t level, const ImageD
// initialization which is already very expensive.
bool allImagesInitialized = true;
for (const ImageDesc &desc : mImageDescs)
for (const ImageDesc &initDesc : mImageDescs)
{
if (desc.initState == InitState::MayNeedInit)
if (initDesc.initState == InitState::MayNeedInit)
{
allImagesInitialized = false;
break;
......
......@@ -324,9 +324,9 @@ CLProgramImpl::Ptr CLContextCL::linkProgram(const cl::Program &program,
!nativeDevices.empty() ? nativeDevices.data() : nullptr;
std::vector<cl_program> nativePrograms;
for (const cl::ProgramPtr &program : inputPrograms)
for (const cl::ProgramPtr &inputProgram : inputPrograms)
{
nativePrograms.emplace_back(program->getImpl<CLProgramCL>().getNative());
nativePrograms.emplace_back(inputProgram->getImpl<CLProgramCL>().getNative());
}
const cl_uint numInputHeaders = static_cast<cl_uint>(nativePrograms.size());
......
......@@ -93,7 +93,7 @@ angle::Result Sync::clientWait(ContextMtl *contextMtl,
[mMetalSharedEvent.get() notifyListener:eventListener
atValue:mSetCounter
block:^(id<MTLSharedEvent> sharedEvent, uint64_t value) {
std::unique_lock<std::mutex> lg(*lockRef);
std::unique_lock<std::mutex> localLock(*lockRef);
cvRef->notify_one();
}];
......
......@@ -46,13 +46,13 @@ void InitializeSubmitInfo(VkSubmitInfo *submitInfo,
bool CommandsHaveValidOrdering(const std::vector<vk::CommandBatch> &commands)
{
Serial currentSerial;
for (const vk::CommandBatch &commands : commands)
for (const vk::CommandBatch &commandBatch : commands)
{
if (commands.serial <= currentSerial)
if (commandBatch.serial <= currentSerial)
{
return false;
}
currentSerial = commands.serial;
currentSerial = commandBatch.serial;
}
return true;
......
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