Read the contents of the SPIR-V OpSource instruction and any following continuation instructions. Split the single string into a vector of strings, one for each line, for easier processing.
| 79 | // Read the contents of the SPIR-V OpSource instruction and any following continuation instructions. |
| 80 | // Split the single string into a vector of strings, one for each line, for easier processing. |
| 81 | static void ReadOpSource(const std::vector<uint32_t>& instructions, const uint32_t reported_file_id, |
| 82 | std::vector<std::string>& out_source_lines) { |
| 83 | uint32_t offset = kModuleStartingOffset; |
| 84 | while (offset < instructions.size()) { |
| 85 | const uint32_t instruction = instructions[offset]; |
| 86 | const uint32_t length = Length(instruction); |
| 87 | const uint32_t opcode = Opcode(instruction); |
| 88 | if (opcode == spv::OpSource && length >= 5 && instructions[offset + 3] == reported_file_id) { |
| 89 | const char* source_text = reinterpret_cast<const char*>(&instructions[offset + 4]); |
| 90 | AppendSourceText(source_text, out_source_lines); |
| 91 | offset += length; // point to next instruction after OpSource |
| 92 | break; |
| 93 | } |
| 94 | offset += length; |
| 95 | } |
| 96 | |
| 97 | // Look for OpSourceContinued, it must be right after |
| 98 | while (offset < instructions.size()) { |
| 99 | const uint32_t continue_insn = instructions[offset]; |
| 100 | const uint32_t length = Length(continue_insn); |
| 101 | const uint32_t opcode = Opcode(continue_insn); |
| 102 | if (opcode != spv::OpSourceContinued) { |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | const char* continue_text = reinterpret_cast<const char*>(&instructions[offset + 1]); |
| 107 | AppendSourceText(continue_text, out_source_lines); |
| 108 | offset += length; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | static void ReadDebugSource(const std::vector<uint32_t>& instructions, const uint32_t debug_source_id, uint32_t& out_file_string_id, |
| 113 | std::vector<std::string>& out_source_lines) { |
no test coverage detected