diff options
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 6d7c7ae..019f18a 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -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. |