From 5b5c5e75554fa603d461df5135d41f364f7e71a3 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 25 Oct 2016 00:08:33 +0000 Subject: [PATCH] [llvm-cov] Do not print out the filename of the object file When we load coverage data from multiple objects, we don't have a way to attribute a source object to a function record. Printing out the object filename next to the source filename is already not very useful: soon, it'll actually become misleading. Stop printing out the filename now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285043 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Inputs/binary-formats.canonical.json | 4 ++-- .../llvm-cov/Inputs/highlightedRanges.json | 4 ++-- .../llvm-cov/Inputs/lineExecutionCounts.json | 4 ++-- test/tools/llvm-cov/Inputs/regionMarkers.json | 4 ++-- .../tools/llvm-cov/Inputs/showExpansions.json | 4 ++-- .../llvm-cov/Inputs/showProjectSummary.test | 3 +-- .../llvm-cov/Inputs/universal-binary.json | 4 ++-- test/tools/llvm-cov/native_separators.c | 2 +- tools/llvm-cov/CodeCoverage.cpp | 12 ++---------- tools/llvm-cov/CoverageExporterJson.cpp | 19 +++++-------------- tools/llvm-cov/CoverageViewOptions.h | 1 - tools/llvm-cov/SourceCoverageView.cpp | 5 ----- tools/llvm-cov/SourceCoverageView.h | 4 ---- tools/llvm-cov/SourceCoverageViewHTML.cpp | 7 ++----- tools/llvm-cov/SourceCoverageViewText.cpp | 4 ++-- 15 files changed, 25 insertions(+), 56 deletions(-) diff --git a/test/tools/llvm-cov/Inputs/binary-formats.canonical.json b/test/tools/llvm-cov/Inputs/binary-formats.canonical.json index 46ada64e7319..19147e2f29bb 100644 --- a/test/tools/llvm-cov/Inputs/binary-formats.canonical.json +++ b/test/tools/llvm-cov/Inputs/binary-formats.canonical.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}binary-formats.c", diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.json b/test/tools/llvm-cov/Inputs/highlightedRanges.json index ddd472e44ec9..3713a4ea7c4e 100644 --- a/test/tools/llvm-cov/Inputs/highlightedRanges.json +++ b/test/tools/llvm-cov/Inputs/highlightedRanges.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}showHighlightedRanges.cpp", diff --git a/test/tools/llvm-cov/Inputs/lineExecutionCounts.json b/test/tools/llvm-cov/Inputs/lineExecutionCounts.json index e07d0982677b..7185d3fbf004 100644 --- a/test/tools/llvm-cov/Inputs/lineExecutionCounts.json +++ b/test/tools/llvm-cov/Inputs/lineExecutionCounts.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}showLineExecutionCounts.cpp", diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.json b/test/tools/llvm-cov/Inputs/regionMarkers.json index 9048768c8eef..d94bdf6e82f1 100644 --- a/test/tools/llvm-cov/Inputs/regionMarkers.json +++ b/test/tools/llvm-cov/Inputs/regionMarkers.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}showRegionMarkers.cpp", diff --git a/test/tools/llvm-cov/Inputs/showExpansions.json b/test/tools/llvm-cov/Inputs/showExpansions.json index 6821fd6ac8a1..893e25a5dd03 100644 --- a/test/tools/llvm-cov/Inputs/showExpansions.json +++ b/test/tools/llvm-cov/Inputs/showExpansions.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}showExpansions.cpp", diff --git a/test/tools/llvm-cov/Inputs/showProjectSummary.test b/test/tools/llvm-cov/Inputs/showProjectSummary.test index 4fb82fbdddc9..eb0222677eaa 100644 --- a/test/tools/llvm-cov/Inputs/showProjectSummary.test +++ b/test/tools/llvm-cov/Inputs/showProjectSummary.test @@ -1,14 +1,13 @@ TEXT-TITLE: Test Suite TEXT-NOT: Coverage Report TEXT-NOT: Created: -TEXT-FILE-NOT: (Binary: showProjectSummary.covmapping) TEXT-FUNCTION: main: TEXT-FOOTER: Generated by llvm-cov HTML-TITLE:

Test Suite

HTML:

Coverage Report

HTML:

Created:{{.*}}

-HTML-FILE:
{{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)
+HTML-FILE:
{{.*}}showProjectSummary.cpp
HTML-FUNCTION:
main
HTML-HEADER:
Line
HTML-HEADER:
Count
diff --git a/test/tools/llvm-cov/Inputs/universal-binary.json b/test/tools/llvm-cov/Inputs/universal-binary.json index ec32adbe2a59..54b9e228b4fb 100644 --- a/test/tools/llvm-cov/Inputs/universal-binary.json +++ b/test/tools/llvm-cov/Inputs/universal-binary.json @@ -1,8 +1,8 @@ // Metadata section -// CHECK: {"version":"1.1.0","type":"llvm.coverage.json.export","data":[ +// CHECK: {"version":"{{[0-9]\.[0-9]\.[0-9]}}","type":"llvm.coverage.json.export","data":[ // Open Export -// CHECK-SAME: {"object":"{{[^"]+}}","files":[ +// CHECK-SAME: {"files":[ // File Object // CHECK-SAME: {"filename":"{{[^"]+}}universal-binary.c", diff --git a/test/tools/llvm-cov/native_separators.c b/test/tools/llvm-cov/native_separators.c index 3db888689c45..adc167bf3d7e 100644 --- a/test/tools/llvm-cov/native_separators.c +++ b/test/tools/llvm-cov/native_separators.c @@ -15,6 +15,6 @@ // TEXT-INDEX: \tmp\native_separators.c // HTML-INDEX: >tmp\native_separators.c -// HTML:
\tmp\native_separators.c (Binary: native_separators.covmapping)
+// HTML:
\tmp\native_separators.c
int main() {} diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp index 15d257914a5b..6bd61d3ef754 100644 --- a/tools/llvm-cov/CodeCoverage.cpp +++ b/tools/llvm-cov/CodeCoverage.cpp @@ -39,8 +39,7 @@ using namespace llvm; using namespace coverage; -void exportCoverageDataToJson(StringRef ObjectFilename, - const coverage::CoverageMapping &CoverageMapping, +void exportCoverageDataToJson(const coverage::CoverageMapping &CoverageMapping, raw_ostream &OS); namespace { @@ -570,13 +569,6 @@ 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; - } - sys::path::native(ObjectFilePath); - ViewOpts.ObjectFilename = ObjectFilePath.c_str(); switch (ViewOpts.Format) { case CoverageViewOptions::OutputFormat::Text: ViewOpts.Colors = UseColor == cl::BOU_UNSET @@ -843,7 +835,7 @@ int CodeCoverageTool::export_(int argc, const char **argv, return 1; } - exportCoverageDataToJson(ObjectFilename, *Coverage.get(), outs()); + exportCoverageDataToJson(*Coverage.get(), outs()); return 0; } diff --git a/tools/llvm-cov/CoverageExporterJson.cpp b/tools/llvm-cov/CoverageExporterJson.cpp index 1b5a1ac01c55..ef50bba21238 100644 --- a/tools/llvm-cov/CoverageExporterJson.cpp +++ b/tools/llvm-cov/CoverageExporterJson.cpp @@ -48,7 +48,7 @@ #include /// \brief The semantic version combined as a string. -#define LLVM_COVERAGE_EXPORT_JSON_STR "1.1.0" +#define LLVM_COVERAGE_EXPORT_JSON_STR "2.0.0" /// \brief Unique type identifier for JSON coverage export. #define LLVM_COVERAGE_EXPORT_JSON_TYPE_STR "llvm.coverage.json.export" @@ -57,9 +57,6 @@ using namespace llvm; using namespace coverage; class CoverageExporterJson { - /// \brief A Name of the object file coverage is for. - StringRef ObjectFilename; - /// \brief Output stream to print JSON to. raw_ostream &OS; @@ -72,9 +69,6 @@ class CoverageExporterJson { /// \brief Tracks state of the JSON output. std::stack State; - /// \brief Get the object filename. - StringRef getObjectFilename() const { return ObjectFilename; } - /// \brief Emit a serialized scalar. void emitSerialized(const int64_t Value) { OS << Value; } @@ -170,7 +164,6 @@ class CoverageExporterJson { // Start Export. emitDictStart(); - emitDictElement("object", getObjectFilename()); emitDictKey("files"); @@ -410,9 +403,8 @@ class CoverageExporterJson { } public: - CoverageExporterJson(StringRef ObjectFilename, - const CoverageMapping &CoverageMapping, raw_ostream &OS) - : ObjectFilename(ObjectFilename), OS(OS), Coverage(CoverageMapping) { + CoverageExporterJson(const CoverageMapping &CoverageMapping, raw_ostream &OS) + : OS(OS), Coverage(CoverageMapping) { State.push(JsonState::None); } @@ -421,10 +413,9 @@ class CoverageExporterJson { }; /// \brief Export the given CoverageMapping to a JSON Format. -void exportCoverageDataToJson(StringRef ObjectFilename, - const CoverageMapping &CoverageMapping, +void exportCoverageDataToJson(const CoverageMapping &CoverageMapping, raw_ostream &OS) { - auto Exporter = CoverageExporterJson(ObjectFilename, CoverageMapping, OS); + auto Exporter = CoverageExporterJson(CoverageMapping, OS); Exporter.print(); } diff --git a/tools/llvm-cov/CoverageViewOptions.h b/tools/llvm-cov/CoverageViewOptions.h index faa46da53ed3..266b380b7d39 100644 --- a/tools/llvm-cov/CoverageViewOptions.h +++ b/tools/llvm-cov/CoverageViewOptions.h @@ -36,7 +36,6 @@ struct CoverageViewOptions { std::vector DemanglerOpts; uint32_t TabSize; std::string ProjectTitle; - std::string ObjectFilename; std::string CreatedTimeStr; /// \brief Change the output's stream color if the colors are enabled. diff --git a/tools/llvm-cov/SourceCoverageView.cpp b/tools/llvm-cov/SourceCoverageView.cpp index 8b3ffe7c63a0..52b8ff1747fe 100644 --- a/tools/llvm-cov/SourceCoverageView.cpp +++ b/tools/llvm-cov/SourceCoverageView.cpp @@ -149,11 +149,6 @@ std::string SourceCoverageView::getSourceName() const { return SourceText.str(); } -std::string SourceCoverageView::getVerboseSourceName() const { - return getSourceName() + " (Binary: " + - sys::path::filename(getOptions().ObjectFilename).str() + ")"; -} - void SourceCoverageView::addExpansion( const coverage::CounterMappingRegion &Region, std::unique_ptr View) { diff --git a/tools/llvm-cov/SourceCoverageView.h b/tools/llvm-cov/SourceCoverageView.h index 2069fe56d8c4..21672f5e7381 100644 --- a/tools/llvm-cov/SourceCoverageView.h +++ b/tools/llvm-cov/SourceCoverageView.h @@ -277,10 +277,6 @@ class SourceCoverageView { /// \brief Return the source name formatted for the host OS. std::string getSourceName() const; - /// \brief Return a verbose description of the source name and the binary it - /// corresponds to. - std::string getVerboseSourceName() const; - const CoverageViewOptions &getOptions() const { return Options; } /// \brief Add an expansion subview to this view. diff --git a/tools/llvm-cov/SourceCoverageViewHTML.cpp b/tools/llvm-cov/SourceCoverageViewHTML.cpp index 2707260b8add..b43db61d89d4 100644 --- a/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -406,11 +406,8 @@ void SourceCoverageViewHTML::renderViewFooter(raw_ostream &OS) { } void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile) { - OS << BeginSourceNameDiv; - std::string ViewInfo = escape( - WholeFile ? getVerboseSourceName() : getSourceName(), getOptions()); - OS << tag("pre", ViewInfo); - OS << EndSourceNameDiv; + OS << BeginSourceNameDiv << tag("pre", escape(getSourceName(), getOptions())) + << EndSourceNameDiv; } void SourceCoverageViewHTML::renderLinePrefix(raw_ostream &OS, unsigned) { diff --git a/tools/llvm-cov/SourceCoverageViewText.cpp b/tools/llvm-cov/SourceCoverageViewText.cpp index 68891298a07b..4ad120f642eb 100644 --- a/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/tools/llvm-cov/SourceCoverageViewText.cpp @@ -70,8 +70,8 @@ void SourceCoverageViewText::renderViewHeader(raw_ostream &) {} void SourceCoverageViewText::renderViewFooter(raw_ostream &) {} void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile) { - std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName(); - getOptions().colored_ostream(OS, raw_ostream::CYAN) << ViewInfo << ":\n"; + getOptions().colored_ostream(OS, raw_ostream::CYAN) << getSourceName() + << ":\n"; } void SourceCoverageViewText::renderLinePrefix(raw_ostream &OS,