Returns true if all decorations that affect the data layout of the struct (like Offset), are the same for the two types. |type1| and |type2| must be OpTypeStruct instructions.
| 102 | // (like Offset), are the same for the two types. |type1| and |type2| must be |
| 103 | // OpTypeStruct instructions. |
| 104 | bool HaveSameLayoutDecorations(ValidationState_t& _, const Instruction* type1, |
| 105 | const Instruction* type2) { |
| 106 | assert(type1->opcode() == spv::Op::OpTypeStruct && |
| 107 | "type1 must be an OpTypeStruct instruction."); |
| 108 | assert(type2->opcode() == spv::Op::OpTypeStruct && |
| 109 | "type2 must be an OpTypeStruct instruction."); |
| 110 | const std::set<Decoration>& type1_decorations = _.id_decorations(type1->id()); |
| 111 | const std::set<Decoration>& type2_decorations = _.id_decorations(type2->id()); |
| 112 | |
| 113 | // TODO: Will have to add other check for arrays an matricies if we want to |
| 114 | // handle them. |
| 115 | if (HasConflictingMemberOffsets(type1_decorations, type2_decorations)) { |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | bool HasConflictingMemberOffsets( |
| 123 | const std::set<Decoration>& type1_decorations, |
no test coverage detected