| 155 | } |
| 156 | |
| 157 | void Summaries::loadReturn(const std::string &buildDir, std::set<std::string> &summaryReturn) |
| 158 | { |
| 159 | if (buildDir.empty()) |
| 160 | return; |
| 161 | |
| 162 | std::vector<std::string> return1; |
| 163 | std::map<std::string, std::vector<std::string>> functionCalls; |
| 164 | std::map<std::string, std::vector<std::string>> functionCalledBy; |
| 165 | |
| 166 | // extract "functionNoreturn" and "functionCalledBy" from summaries |
| 167 | std::vector<std::string> summaryFiles = getSummaryFiles(buildDir + "/files.txt"); |
| 168 | for (const std::string &filename: summaryFiles) { |
| 169 | std::ifstream fin(buildDir + '/' + filename); |
| 170 | if (!fin.is_open()) |
| 171 | continue; |
| 172 | std::string line; |
| 173 | while (std::getline(fin, line)) { |
| 174 | // Get function name |
| 175 | constexpr std::string::size_type pos1 = 0; |
| 176 | const std::string::size_type pos2 = line.find(' ', pos1); |
| 177 | std::string functionName = (pos2 == std::string::npos) ? line : line.substr(0, pos2); |
| 178 | std::vector<std::string> call = getSummaryData(line, "call"); |
| 179 | if (call.empty()) |
| 180 | return1.push_back(functionName); |
| 181 | else { |
| 182 | for (const std::string &c: call) { |
| 183 | functionCalledBy[c].push_back(functionName); |
| 184 | } |
| 185 | } |
| 186 | functionCalls[functionName] = std::move(call); |
| 187 | } |
| 188 | } |
| 189 | summaryReturn.insert(return1.cbegin(), return1.cend()); |
| 190 | |
| 191 | // recursively set "summaryNoreturn" |
| 192 | for (const std::string &f: return1) { |
| 193 | std::vector<std::string> return2; |
| 194 | removeFunctionCalls(f, functionCalledBy, functionCalls, return2); |
| 195 | summaryReturn.insert(return2.cbegin(), return2.cend()); |
| 196 | } |
| 197 | } |
nothing calls this directly
no test coverage detected