Index: test/tools/llvm-cov/native_separators.c =================================================================== --- test/tools/llvm-cov/native_separators.c +++ test/tools/llvm-cov/native_separators.c @@ -19,3 +19,8 @@ // HTML: tools\llvm-cov\Inputs\native_separators.covmapping int main() {} + +// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence %s -o %t.dir +// RUN: FileCheck -check-prefixes=TEXT -input-file=%t.dir/coverage/tmp/native_separators.c.txt %s +// TEXT: {{^}}Source: \tmp\native_separators.c:{{$}} +// TEXT: {{^}}Binary: {{.*}}tools\llvm-cov\Inputs\native_separators.covmapping:{{$}} Index: test/tools/llvm-cov/showTemplateInstantiations.cpp =================================================================== --- test/tools/llvm-cov/showTemplateInstantiations.cpp +++ test/tools/llvm-cov/showTemplateInstantiations.cpp @@ -12,7 +12,7 @@ int j = 1; // ALL-NEXT: [[@LINE]]| 0| int j = 1; } // ALL-NEXT: [[@LINE]]| 2|} - // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_: + // SHARED: {{^ *(\| )?}}Function: _Z4funcIbEiT_: // SHARED: [[@LINE-9]]| 1|int func(T x) { // SHARED-NEXT: [[@LINE-9]]| 1| if(x) // SHARED-NEXT: [[@LINE-9]]| 1| return 0; @@ -21,8 +21,8 @@ // SHARED-NEXT: [[@LINE-9]]| 0| int j = 1; // SHARED-NEXT: [[@LINE-9]]| 1|} - // ALL: {{^ *}}| _Z4funcIiEiT_: - // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_: + // ALL: {{^ *}}| Function: _Z4funcIiEiT_: + // FILTER-NOT: {{^ *(\| )?}}Function: _Z4funcIiEiT_: // ALL: [[@LINE-19]]| 1|int func(T x) { // ALL-NEXT: [[@LINE-19]]| 1| if(x) // ALL-NEXT: [[@LINE-19]]| 0| return 0; Index: tools/llvm-cov/CodeCoverage.cpp =================================================================== --- tools/llvm-cov/CodeCoverage.cpp +++ tools/llvm-cov/CodeCoverage.cpp @@ -669,7 +669,7 @@ // Show files bool ShowFilenames = - (SourceFiles.size() != 1) || + (SourceFiles.size() != 1) || ViewOpts.hasOutputDirectory() || (ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML); if (SourceFiles.empty()) Index: tools/llvm-cov/SourceCoverageView.h =================================================================== --- tools/llvm-cov/SourceCoverageView.h +++ tools/llvm-cov/SourceCoverageView.h @@ -274,6 +274,8 @@ StringRef getSourceName() const { return SourceName; } + std::string getNativeSourceName() const; + bool isFunctionView() const { return FunctionView; } const CoverageViewOptions &getOptions() const { return Options; } Index: tools/llvm-cov/SourceCoverageView.cpp =================================================================== --- tools/llvm-cov/SourceCoverageView.cpp +++ tools/llvm-cov/SourceCoverageView.cpp @@ -123,6 +123,15 @@ llvm_unreachable("Unknown coverage output format!"); } +std::string SourceCoverageView::getNativeSourceName() const { + std::string SourceFile = isFunctionView() ? "Function: " : "Source: "; + SourceFile += getSourceName().str(); + SmallString<128> SourceText(SourceFile); + sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true); + sys::path::native(SourceText); + return SourceText.c_str(); +} + void SourceCoverageView::addExpansion( const coverage::CounterMappingRegion &Region, std::unique_ptr View) { Index: tools/llvm-cov/SourceCoverageViewHTML.cpp =================================================================== --- tools/llvm-cov/SourceCoverageViewHTML.cpp +++ tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -341,12 +341,7 @@ void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile) { OS << BeginSourceNameDiv; // Render the source name for the view. - std::string SourceFile = isFunctionView() ? "Function: " : "Source: "; - SourceFile += getSourceName().str(); - SmallString<128> SourceText(SourceFile); - sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true); - sys::path::native(SourceText); - OS << tag("pre", escape(SourceText, getOptions())); + OS << tag("pre", escape(getNativeSourceName(), getOptions())); // Render the object file name for the view. if (WholeFile) OS << tag("pre", Index: tools/llvm-cov/SourceCoverageViewText.cpp =================================================================== --- tools/llvm-cov/SourceCoverageViewText.cpp +++ tools/llvm-cov/SourceCoverageViewText.cpp @@ -64,11 +64,11 @@ void SourceCoverageViewText::renderViewFooter(raw_ostream &) {} void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile) { - getOptions().colored_ostream(OS, raw_ostream::CYAN) << getSourceName() + getOptions().colored_ostream(OS, raw_ostream::CYAN) << getNativeSourceName() << ":\n"; if (WholeFile) { getOptions().colored_ostream(OS, raw_ostream::CYAN) - << getOptions().ObjectFilename << ":\n"; + << "Binary: " << getOptions().ObjectFilename << ":\n"; } }