Skip to content

Commit

Permalink
[llvm-cov] Do not print out the filename of the object file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vedantk committed Oct 25, 2016
1 parent 01b8943 commit 5b5c5e7
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 56 deletions.
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/binary-formats.canonical.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/highlightedRanges.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/lineExecutionCounts.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/regionMarkers.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/showExpansions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 1 addition & 2 deletions test/tools/llvm-cov/Inputs/showProjectSummary.test
Original file line number Diff line number Diff line change
@@ -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: <h1>Test Suite</h1>
HTML: <h2>Coverage Report</h2>
HTML: <h4>Created:{{.*}}</h4>
HTML-FILE: <pre>{{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
HTML-FILE: <pre>{{.*}}showProjectSummary.cpp</pre>
HTML-FUNCTION: <pre>main</pre>
HTML-HEADER: <td><pre>Line</pre></td>
HTML-HEADER: <td><pre>Count</pre></td>
Expand Down
4 changes: 2 additions & 2 deletions test/tools/llvm-cov/Inputs/universal-binary.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/tools/llvm-cov/native_separators.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

// TEXT-INDEX: \tmp\native_separators.c
// HTML-INDEX: >tmp\native_separators.c</a>
// HTML: <pre>\tmp\native_separators.c (Binary: native_separators.covmapping)</pre>
// HTML: <pre>\tmp\native_separators.c</pre>

int main() {}
12 changes: 2 additions & 10 deletions tools/llvm-cov/CodeCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
19 changes: 5 additions & 14 deletions tools/llvm-cov/CoverageExporterJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include <stack>

/// \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"
Expand All @@ -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;

Expand All @@ -72,9 +69,6 @@ class CoverageExporterJson {
/// \brief Tracks state of the JSON output.
std::stack<JsonState> State;

/// \brief Get the object filename.
StringRef getObjectFilename() const { return ObjectFilename; }

/// \brief Emit a serialized scalar.
void emitSerialized(const int64_t Value) { OS << Value; }

Expand Down Expand Up @@ -170,7 +164,6 @@ class CoverageExporterJson {

// Start Export.
emitDictStart();
emitDictElement("object", getObjectFilename());

emitDictKey("files");

Expand Down Expand Up @@ -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);
}

Expand All @@ -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();
}
1 change: 0 additions & 1 deletion tools/llvm-cov/CoverageViewOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct CoverageViewOptions {
std::vector<std::string> 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.
Expand Down
5 changes: 0 additions & 5 deletions tools/llvm-cov/SourceCoverageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SourceCoverageView> View) {
Expand Down
4 changes: 0 additions & 4 deletions tools/llvm-cov/SourceCoverageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions tools/llvm-cov/SourceCoverageViewHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tools/llvm-cov/SourceCoverageViewText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5b5c5e7

Please sign in to comment.