auto SubViewExpansions = ExpansionCoverage.getExpansions();
auto SubView = llvm::make_unique<SourceCoverageView>(
- SourceBuffer.get(), ViewOpts, std::move(ExpansionCoverage));
+ Expansion.Function.Name, SourceBuffer.get(), ViewOpts,
+ std::move(ExpansionCoverage));
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
View.addExpansion(Expansion.Region, std::move(SubView));
}
auto Expansions = FunctionCoverage.getExpansions();
auto View = llvm::make_unique<SourceCoverageView>(
- SourceBuffer.get(), ViewOpts, std::move(FunctionCoverage));
+ Function.Name, SourceBuffer.get(), ViewOpts, std::move(FunctionCoverage));
attachExpansionSubViews(*View, Expansions, Coverage);
return View;
auto Expansions = FileCoverage.getExpansions();
auto View = llvm::make_unique<SourceCoverageView>(
- SourceBuffer.get(), ViewOpts, std::move(FileCoverage));
+ SourceFile, SourceBuffer.get(), ViewOpts, std::move(FileCoverage));
attachExpansionSubViews(*View, Expansions, Coverage);
for (auto Function : Coverage.getInstantiations(SourceFile)) {
auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
auto SubViewExpansions = SubViewCoverage.getExpansions();
auto SubView = llvm::make_unique<SourceCoverageView>(
- SourceBuffer.get(), ViewOpts, std::move(SubViewCoverage));
+ Function->Name, SourceBuffer.get(), ViewOpts,
+ std::move(SubViewCoverage));
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
if (SubView) {
outs() << "\n";
continue;
}
- ViewOpts.colored_ostream(outs(), raw_ostream::CYAN) << Function.Name
- << ":";
- outs() << "\n";
+ mainView->renderSourceName(outs());
mainView->render(outs(), /*WholeFile=*/false);
outs() << "\n";
}
continue;
}
- if (ShowFilenames) {
- ViewOpts.colored_ostream(outs(), raw_ostream::CYAN) << SourceFile << ":";
- outs() << "\n";
- }
+ if (ShowFilenames)
+ mainView->renderSourceName(outs());
+
mainView->render(outs(), /*Wholefile=*/true);
if (SourceFiles.size() > 1)
outs() << "\n";
/// It can have embedded coverage views.
class SourceCoverageView {
private:
+ /// A function or file name.
+ StringRef SourceName;
+
+ /// A memory buffer backing the source on display.
const MemoryBuffer &File;
+
+ /// Various options to guide the coverage renderer.
const CoverageViewOptions &Options;
+
+ /// Complete coverage information about the source on display.
coverage::CoverageData CoverageInfo;
+
+ /// A container for all expansions (e.g macros) in the source on display.
std::vector<ExpansionView> ExpansionSubViews;
+
+ /// A container for all instantiations (e.g template functions) in the source
+ /// on display.
std::vector<InstantiationView> InstantiationSubViews;
/// \brief Render a source line with highlighting.
static const unsigned LineNumberColumnWidth = 5;
public:
- SourceCoverageView(const MemoryBuffer &File,
+ SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
coverage::CoverageData &&CoverageInfo)
- : File(File), Options(Options), CoverageInfo(std::move(CoverageInfo)) {}
+ : SourceName(SourceName), File(File), Options(Options),
+ CoverageInfo(std::move(CoverageInfo)) {}
+
+ StringRef getSourceName() const { return SourceName; }
const CoverageViewOptions &getOptions() const { return Options; }
/// \brief Print the code coverage information for a specific
/// portion of a source file to the output stream.
void render(raw_ostream &OS, bool WholeFile, unsigned IndentLevel = 0);
+
+ /// \brief Print the source name corresponding to this view.
+ void renderSourceName(raw_ostream &OS);
};
} // namespace llvm