[llvm-cov] Add the project summary to each source file coverage report.
This patch includes the following changes: - Included header "Code coverage report" and include the date that the report was created. - Included title (as specified in a command line option, (i.e llvm-cov -project-title="Simple Test") - In the summary, list the elf files that the source code file has contributed to. - Used column heading for "Line No.", "Count No.", Source". Differential Revision: https://reviews.llvm.org/D23345 llvm-svn: 279628
This commit is contained in:
@@ -210,9 +210,9 @@ CodeCoverageTool::createFunctionView(const FunctionRecord &Function,
|
||||
return nullptr;
|
||||
|
||||
auto Expansions = FunctionCoverage.getExpansions();
|
||||
auto View = SourceCoverageView::create(getSymbolForHumans(Function.Name),
|
||||
SourceBuffer.get(), ViewOpts,
|
||||
std::move(FunctionCoverage));
|
||||
auto View = SourceCoverageView::create(
|
||||
getSymbolForHumans(Function.Name), SourceBuffer.get(), ViewOpts,
|
||||
std::move(FunctionCoverage), /*FunctionView=*/true);
|
||||
attachExpansionSubViews(*View, Expansions, Coverage);
|
||||
|
||||
return View;
|
||||
@@ -238,7 +238,7 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
|
||||
auto SubViewExpansions = SubViewCoverage.getExpansions();
|
||||
auto SubView = SourceCoverageView::create(
|
||||
getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
|
||||
std::move(SubViewCoverage));
|
||||
std::move(SubViewCoverage), /*FunctionView=*/true);
|
||||
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
|
||||
|
||||
if (SubView) {
|
||||
@@ -463,6 +463,12 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
|
||||
CompareFilenamesOnly = FilenameEquivalence;
|
||||
|
||||
ViewOpts.Format = Format;
|
||||
SmallString<128> ObjectFilePath(this->ObjectFilename);
|
||||
if (std::error_code EC = sys::fs::make_absolute(ObjectFilePath)) {
|
||||
error(EC.message(), this->ObjectFilename);
|
||||
return 1;
|
||||
}
|
||||
ViewOpts.ObjectFilename = ObjectFilePath.c_str();
|
||||
switch (ViewOpts.Format) {
|
||||
case CoverageViewOptions::OutputFormat::Text:
|
||||
ViewOpts.Colors = UseColor == cl::BOU_UNSET
|
||||
@@ -589,6 +595,10 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
cl::desc(
|
||||
"Set tab expansion size for html coverage reports (default = 2)"));
|
||||
|
||||
cl::opt<std::string> ProjectTitle(
|
||||
"project-title", cl::Optional,
|
||||
cl::desc("Set project title for the coverage report"));
|
||||
|
||||
auto Err = commandLineParser(argc, argv);
|
||||
if (Err)
|
||||
return Err;
|
||||
@@ -602,6 +612,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
ViewOpts.ShowFunctionInstantiations = ShowInstantiations;
|
||||
ViewOpts.ShowOutputDirectory = ShowOutputDirectory;
|
||||
ViewOpts.TabSize = TabSize;
|
||||
ViewOpts.ProjectTitle = ProjectTitle;
|
||||
|
||||
if (ViewOpts.hasOutputDirectory()) {
|
||||
if (auto E = sys::fs::create_directories(ViewOpts.ShowOutputDirectory)) {
|
||||
@@ -610,6 +621,19 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
}
|
||||
}
|
||||
|
||||
sys::fs::file_status Status;
|
||||
if (sys::fs::status(PGOFilename, Status)) {
|
||||
error("profdata file error: can not get the file status. \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto ModifiedTime = Status.getLastModificationTime();
|
||||
std::string ModifiedTimeStr = ModifiedTime.str();
|
||||
size_t found = ModifiedTimeStr.rfind(":");
|
||||
ViewOpts.CreatedTimeStr = (found != std::string::npos)
|
||||
? "Created: " + ModifiedTimeStr.substr(0, found)
|
||||
: "Created: " + ModifiedTimeStr;
|
||||
|
||||
auto Coverage = load();
|
||||
if (!Coverage)
|
||||
return 1;
|
||||
@@ -643,7 +667,9 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
}
|
||||
|
||||
// Show files
|
||||
bool ShowFilenames = SourceFiles.size() != 1;
|
||||
bool ShowFilenames =
|
||||
(SourceFiles.size() != 1) ||
|
||||
(ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML);
|
||||
|
||||
if (SourceFiles.empty())
|
||||
// Get the source files from the function coverage mapping.
|
||||
|
||||
Reference in New Issue
Block a user