| 80 | } |
| 81 | |
| 82 | bool Function::WhileEachInst(const std::function<bool(Instruction*)>& f, |
| 83 | bool run_on_debug_line_insts, |
| 84 | bool run_on_non_semantic_insts) { |
| 85 | if (def_inst_) { |
| 86 | if (!def_inst_->WhileEachInst(f, run_on_debug_line_insts)) { |
| 87 | return false; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | for (auto& param : params_) { |
| 92 | if (!param->WhileEachInst(f, run_on_debug_line_insts)) { |
| 93 | return false; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | if (!debug_insts_in_header_.empty()) { |
| 98 | Instruction* di = &debug_insts_in_header_.front(); |
| 99 | while (di != nullptr) { |
| 100 | Instruction* next_instruction = di->NextNode(); |
| 101 | if (!di->WhileEachInst(f, run_on_debug_line_insts)) return false; |
| 102 | di = next_instruction; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | for (auto& bb : blocks_) { |
| 107 | if (!bb->WhileEachInst(f, run_on_debug_line_insts)) { |
| 108 | return false; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if (end_inst_) { |
| 113 | if (!end_inst_->WhileEachInst(f, run_on_debug_line_insts)) { |
| 114 | return false; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if (run_on_non_semantic_insts) { |
| 119 | for (auto& non_semantic : non_semantic_) { |
| 120 | if (!non_semantic->WhileEachInst(f, run_on_debug_line_insts)) { |
| 121 | return false; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return true; |
| 127 | } |
| 128 | |
| 129 | bool Function::WhileEachInst(const std::function<bool(const Instruction*)>& f, |
| 130 | bool run_on_debug_line_insts, |
no test coverage detected