Avoid variable shadowing
authorDavid Neto <dneto@google.com>
Tue, 5 Jan 2016 19:56:02 +0000 (14:56 -0500)
committerDavid Neto <dneto@google.com>
Wed, 6 Jan 2016 18:11:42 +0000 (13:11 -0500)
source/binary.cpp
source/text.cpp
source/validate.cpp
source/validate_id.cpp

index 99cf30f..7a3ec35 100755 (executable)
@@ -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,
index c86ff6e..3386f18 100755 (executable)
@@ -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;
       }
 
index 80bb4c4..eb4ecc6 100644 (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
index cdb8e59..4901e79 100644 (file)
 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]);
     }