Avoid variable shadowing

This commit is contained in:
David Neto 2016-01-05 14:56:02 -05:00
parent 095a41aca8
commit 677e0c7b49
4 changed files with 21 additions and 20 deletions

View File

@ -463,18 +463,20 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
switch (type) {
case SPV_OPERAND_TYPE_TYPE_ID:
if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Type Id is 0";
if (!word)
return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Type Id is 0";
inst->type_id = word;
break;
case SPV_OPERAND_TYPE_RESULT_ID:
if (!word) return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Result Id is 0";
if (!word)
return diagnostic(SPV_ERROR_INVALID_ID) << "Error: Result Id is 0";
inst->result_id = word;
// Save the result ID to type ID mapping.
// In the grammar, type ID always appears before result ID.
if (_.id_to_type_id.find(inst->result_id) != _.id_to_type_id.end())
return diagnostic(SPV_ERROR_INVALID_ID) << "Id " << inst->result_id
<< " is defined more than once";
<< " is defined more than once";
// Record it.
// A regular value maps to its type. Some instructions (e.g. OpLabel)
// have no type Id, and will map to 0. The result Id for a
@ -736,8 +738,8 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
if (convert_operand_endianness) {
const spv_endianness_t endianness = _.endian;
std::transform(_.words + _.word_index, _.words + index_after_operand,
words->end(), [endianness](const uint32_t word) {
return spvFixWord(word, endianness);
words->end(), [endianness](const uint32_t raw_word) {
return spvFixWord(raw_word, endianness);
});
} else {
words->insert(words->end(), _.words + _.word_index,

View File

@ -368,8 +368,8 @@ spv_result_t spvTextEncodeOperand(const libspirv::AssemblyGrammar& grammar,
<< "Invalid extended instruction import '" << literal.str
<< "'";
}
if (auto error = context->recordIdAsExtInstImport(pInst->words[1],
ext_inst_type))
if ((error = context->recordIdAsExtInstImport(pInst->words[1],
ext_inst_type)))
return error;
}

View File

@ -552,11 +552,10 @@ spv_result_t ProcessInstructions(void* user_data,
// TODO(umar): Perform CFG pass
// TODO(umar): Perform data rules pass
// TODO(umar): Perform instruction validation pass
spv_result_t ret = SPV_SUCCESS;
CHECK_RESULT(ModuleLayoutPass(_, inst))
CHECK_RESULT(SsaPass(_, can_have_forward_declared_ids, inst))
return ret;
return SPV_SUCCESS;
}
} // anonymous namespace

View File

@ -44,20 +44,20 @@
namespace {
class idUsage {
public:
idUsage(const spv_opcode_table opcodeTable,
const spv_operand_table operandTable,
const spv_ext_inst_table extInstTable, const spv_id_info_t* pIdUses,
idUsage(const spv_opcode_table opcodeTableArg,
const spv_operand_table operandTableArg,
const spv_ext_inst_table extInstTableArg, const spv_id_info_t* pIdUses,
const uint64_t idUsesCount, const spv_id_info_t* pIdDefs,
const uint64_t idDefsCount, const spv_instruction_t* pInsts,
const uint64_t instCount, spv_position position,
spv_diagnostic* pDiagnostic)
: opcodeTable(opcodeTable),
operandTable(operandTable),
extInstTable(extInstTable),
const uint64_t instCountArg, spv_position positionArg,
spv_diagnostic* pDiagnosticArg)
: opcodeTable(opcodeTableArg),
operandTable(operandTableArg),
extInstTable(extInstTableArg),
firstInst(pInsts),
instCount(instCount),
position(position),
pDiagnostic(pDiagnostic) {
instCount(instCountArg),
position(positionArg),
pDiagnostic(pDiagnosticArg) {
for (uint64_t idUsesIndex = 0; idUsesIndex < idUsesCount; ++idUsesIndex) {
idUses[pIdUses[idUsesIndex].id].push_back(pIdUses[idUsesIndex]);
}