void CodeCoverageTool::removeUnmappedInputs(const CoverageMapping &Coverage) { std::vector<StringRef> CoveredFiles = Coverage.getUniqueSourceFiles(); auto UncoveredFilesIt = SourceFiles.end(); if (!CompareFilenamesOnly) { // The user may have specified source files which aren't in the coverage // mapping. Filter these files away. UncoveredFilesIt = std::remove_if( SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) { return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(), SF); }); } else { for (auto &SF : SourceFiles) { StringRef SFBase = sys::path::filename(SF); for (const auto &CF : CoveredFiles) { if (SFBase == sys::path::filename(CF)) { RemappedFilenames[CF] = SF; SF = CF; break; } } } UncoveredFilesIt = std::remove_if( SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) { return !RemappedFilenames.count(SF); }); } SourceFiles.erase(UncoveredFilesIt, SourceFiles.end()); }
/// \brief Render the CoverageMapping object. void renderRoot() { // Start Root of JSON object. emitDictStart(); emitDictElement("version", LLVM_COVERAGE_EXPORT_JSON_STR); emitDictElement("type", LLVM_COVERAGE_EXPORT_JSON_TYPE_STR); emitDictKey("data"); // Start List of Exports. emitArrayStart(); // Start Export. emitDictStart(); emitDictElement("object", getObjectFilename()); emitDictKey("files"); FileCoverageSummary Totals = FileCoverageSummary("Totals"); std::vector<std::string> SourceFiles; for (StringRef SF : Coverage.getUniqueSourceFiles()) SourceFiles.emplace_back(SF); auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles); renderFiles(SourceFiles, FileReports); emitDictKey("functions"); renderFunctions(Coverage.getCoveredFunctions()); emitDictKey("totals"); renderSummary(Totals); // End Export. emitDictEnd(); // End List of Exports. emitArrayEnd(); // End Root of JSON Object. emitDictEnd(); assert((State.top() == JsonState::None) && "All Elements In JSON were Closed"); }