Returns true if |a| and |b| are instructions defining pointers that point to types logically match and the decorations that apply to |b| are a subset of the decorations that apply to |a|.
| 28 | // types logically match and the decorations that apply to |b| are a subset |
| 29 | // of the decorations that apply to |a|. |
| 30 | bool DoPointeesLogicallyMatch(val::Instruction* a, val::Instruction* b, |
| 31 | ValidationState_t& _) { |
| 32 | if (a->opcode() != spv::Op::OpTypePointer || |
| 33 | b->opcode() != spv::Op::OpTypePointer) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | const auto& dec_a = _.id_decorations(a->id()); |
| 38 | const auto& dec_b = _.id_decorations(b->id()); |
| 39 | for (const auto& dec : dec_b) { |
| 40 | if (std::find(dec_a.begin(), dec_a.end(), dec) == dec_a.end()) { |
| 41 | return false; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | uint32_t a_type = a->GetOperandAs<uint32_t>(2); |
| 46 | uint32_t b_type = b->GetOperandAs<uint32_t>(2); |
| 47 | |
| 48 | if (a_type == b_type) { |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | Instruction* a_type_inst = _.FindDef(a_type); |
| 53 | Instruction* b_type_inst = _.FindDef(b_type); |
| 54 | |
| 55 | return _.LogicallyMatch(a_type_inst, b_type_inst, true); |
| 56 | } |
| 57 | |
| 58 | spv_result_t ValidateFunction(ValidationState_t& _, const Instruction* inst) { |
| 59 | const auto function_type_id = inst->GetOperandAs<uint32_t>(3); |
no test coverage detected