| 22 | namespace { |
| 23 | |
| 24 | spv_result_t ValidateMemberName(ValidationState_t& _, const Instruction* inst) { |
| 25 | const auto type_id = inst->GetOperandAs<uint32_t>(0); |
| 26 | const auto type = _.FindDef(type_id); |
| 27 | if (!type || spv::Op::OpTypeStruct != type->opcode()) { |
| 28 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 29 | << "OpMemberName Type <id> " << _.getIdName(type_id) |
| 30 | << " is not a struct type."; |
| 31 | } |
| 32 | const auto member_id = inst->GetOperandAs<uint32_t>(1); |
| 33 | const auto member_count = (uint32_t)(type->words().size() - 2); |
| 34 | if (member_count <= member_id) { |
| 35 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 36 | << "OpMemberName Member <id> " << _.getIdName(member_id) |
| 37 | << " index is larger than Type <id> " << _.getIdName(type->id()) |
| 38 | << "s member count."; |
| 39 | } |
| 40 | return SPV_SUCCESS; |
| 41 | } |
| 42 | |
| 43 | spv_result_t ValidateLine(ValidationState_t& _, const Instruction* inst) { |
| 44 | const auto file_id = inst->GetOperandAs<uint32_t>(0); |