-void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) {
- for (StringMap<LineData>::const_iterator I = LineInfo.begin(),
- E = LineInfo.end(); I != E; ++I) {
- StringRef Filename = I->first();
- OwningPtr<MemoryBuffer> Buff;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
- errs() << Filename << ": " << ec.message() << "\n";
- return;
- }
- StringRef AllLines = Buff->getBuffer();
-
- std::string CoveragePath = mangleCoveragePath(Filename,
- Options.PreservePaths);
- std::string ErrorInfo;
- raw_fd_ostream OS(CoveragePath.c_str(), ErrorInfo, sys::fs::F_None);
- if (!ErrorInfo.empty())
- errs() << ErrorInfo << "\n";
-
- OS << " -: 0:Source:" << Filename << "\n";
- OS << " -: 0:Graph:" << GCNOFile << "\n";
- OS << " -: 0:Data:" << GCDAFile << "\n";
- OS << " -: 0:Runs:" << RunCount << "\n";
- OS << " -: 0:Programs:" << ProgramCount << "\n";
-
- const LineData &Line = I->second;
+void FileInfo::print(raw_ostream &InfoOS, StringRef MainFilename,
+ StringRef GCNOFile, StringRef GCDAFile) {
+ for (const auto &LI : LineInfo) {
+ StringRef Filename = LI.first();
+ auto AllLines = LineConsumer(Filename);
+
+ std::string CoveragePath = getCoveragePath(Filename, MainFilename);
+ std::unique_ptr<raw_ostream> CovStream = openCoveragePath(CoveragePath);
+ raw_ostream &CovOS = *CovStream;
+
+ CovOS << " -: 0:Source:" << Filename << "\n";
+ CovOS << " -: 0:Graph:" << GCNOFile << "\n";
+ CovOS << " -: 0:Data:" << GCDAFile << "\n";
+ CovOS << " -: 0:Runs:" << RunCount << "\n";
+ CovOS << " -: 0:Programs:" << ProgramCount << "\n";
+
+ const LineData &Line = LI.second;