| 1073 | } |
| 1074 | |
| 1075 | void IRContext::EmitErrorMessage(std::string message, Instruction* inst) { |
| 1076 | if (!consumer()) { |
| 1077 | return; |
| 1078 | } |
| 1079 | |
| 1080 | Instruction* line_inst = inst; |
| 1081 | while (line_inst != nullptr) { // Stop at the beginning of the basic block. |
| 1082 | if (!line_inst->dbg_line_insts().empty()) { |
| 1083 | line_inst = &line_inst->dbg_line_insts().back(); |
| 1084 | if (line_inst->IsNoLine()) { |
| 1085 | line_inst = nullptr; |
| 1086 | } |
| 1087 | break; |
| 1088 | } |
| 1089 | line_inst = line_inst->PreviousNode(); |
| 1090 | } |
| 1091 | |
| 1092 | uint32_t line_number = 0; |
| 1093 | uint32_t col_number = 0; |
| 1094 | std::string source; |
| 1095 | if (line_inst != nullptr) { |
| 1096 | Instruction* file_name = |
| 1097 | get_def_use_mgr()->GetDef(line_inst->GetSingleWordInOperand(0)); |
| 1098 | source = file_name->GetInOperand(0).AsString(); |
| 1099 | |
| 1100 | // Get the line number and column number. |
| 1101 | line_number = line_inst->GetSingleWordInOperand(1); |
| 1102 | col_number = line_inst->GetSingleWordInOperand(2); |
| 1103 | } |
| 1104 | |
| 1105 | message += |
| 1106 | "\n " + inst->PrettyPrint(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); |
| 1107 | consumer()(SPV_MSG_ERROR, source.c_str(), {line_number, col_number, 0}, |
| 1108 | message.c_str()); |
| 1109 | } |
| 1110 | |
| 1111 | // Gets the dominator analysis for function |f|. |
| 1112 | DominatorAnalysis* IRContext::GetDominatorAnalysis(const Function* f) { |
no test coverage detected