Returns true if the operands to the OpTypeStruct instruction defining the types are the same or are layout compatible types. |type1| and |type2| must be OpTypeStruct instructions.
| 75 | // types are the same or are layout compatible types. |type1| and |type2| must |
| 76 | // be OpTypeStruct instructions. |
| 77 | bool HaveLayoutCompatibleMembers(ValidationState_t& _, const Instruction* type1, |
| 78 | const Instruction* type2) { |
| 79 | assert(type1->opcode() == spv::Op::OpTypeStruct && |
| 80 | "type1 must be an OpTypeStruct instruction."); |
| 81 | assert(type2->opcode() == spv::Op::OpTypeStruct && |
| 82 | "type2 must be an OpTypeStruct instruction."); |
| 83 | const auto& type1_operands = type1->operands(); |
| 84 | const auto& type2_operands = type2->operands(); |
| 85 | if (type1_operands.size() != type2_operands.size()) { |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | for (size_t operand = 2; operand < type1_operands.size(); ++operand) { |
| 90 | if (type1->word(operand) != type2->word(operand)) { |
| 91 | auto def1 = _.FindDef(type1->word(operand)); |
| 92 | auto def2 = _.FindDef(type2->word(operand)); |
| 93 | if (!AreLayoutCompatibleStructs(_, def1, def2)) { |
| 94 | return false; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | // Returns true if all decorations that affect the data layout of the struct |
| 102 | // (like Offset), are the same for the two types. |type1| and |type2| must be |
no test coverage detected