Index: test/tools/llvm-cov/Inputs/path_equivalence.proftext =================================================================== --- test/tools/llvm-cov/Inputs/path_equivalence.proftext +++ test/tools/llvm-cov/Inputs/path_equivalence.proftext @@ -0,0 +1,8 @@ +main +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +1 + Index: test/tools/llvm-cov/binary-formats.c =================================================================== --- test/tools/llvm-cov/binary-formats.c +++ test/tools/llvm-cov/binary-formats.c @@ -4,9 +4,9 @@ int main(int argc, const char *argv[]) {} // RUN: llvm-profdata merge %S/Inputs/binary-formats.proftext -o %t.profdata -// RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s // RUN: llvm-cov export %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json // RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json Index: test/tools/llvm-cov/combine_expansions.cpp =================================================================== --- test/tools/llvm-cov/combine_expansions.cpp +++ test/tools/llvm-cov/combine_expansions.cpp @@ -1,7 +1,7 @@ // Check that we combine expansion regions. // RUN: llvm-profdata merge %S/Inputs/combine_expansions.proftext -o %t.profdata -// RUN: llvm-cov show %S/Inputs/combine_expansions.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/combine_expansions.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/ec,%S %s | FileCheck %s #define SIMPLE_OP \ ++x Index: test/tools/llvm-cov/cov-comdat.test =================================================================== --- test/tools/llvm-cov/cov-comdat.test +++ test/tools/llvm-cov/cov-comdat.test @@ -7,6 +7,6 @@ # of the same template function are properly merged in show # output. -// RUN: llvm-cov show %S/Inputs/binary-formats.v1.linux64l -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h -// RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux64l -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h -// RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux32l -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h +// RUN: llvm-cov show %S/Inputs/binary-formats.v1.linux64l -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h +// RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux64l -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h +// RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux32l -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h Index: test/tools/llvm-cov/demangle.test =================================================================== --- test/tools/llvm-cov/demangle.test +++ test/tools/llvm-cov/demangle.test @@ -1,11 +1,11 @@ -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp | FileCheck %s // Check that we demangle names even if the sub-view will be hidden. RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp | FileCheck %s // Check that we demangle names when printing out function summaries. -RUN: llvm-cov report -show-functions %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s +RUN: llvm-cov report -show-functions %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp | FileCheck %s CHECK-DAG: XZ4funcIbEiTX CHECK-DAG: XZ4funcIiEiTX Index: test/tools/llvm-cov/hideUnexecutedSubviews.test =================================================================== --- test/tools/llvm-cov/hideUnexecutedSubviews.test +++ test/tools/llvm-cov/hideUnexecutedSubviews.test @@ -1,8 +1,8 @@ RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck -check-prefix=FILE %s +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp | FileCheck -check-prefix=FILE %s -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -o %t.html.dir -filename-equivalence %S/showTemplateInstantiations.cpp +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -o %t.html.dir -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp RUN: FileCheck -check-prefix=FILE %s -input-file %t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html FILE: Unexecuted instantiation: _Z4funcIbEiT_ Index: test/tools/llvm-cov/native_separators.c =================================================================== --- test/tools/llvm-cov/native_separators.c +++ test/tools/llvm-cov/native_separators.c @@ -8,9 +8,9 @@ // RUN: llvm-profdata merge %S/Inputs/double_dots.proftext -o %t.profdata // RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -o %t.dir // RUN: FileCheck -check-prefixes=TEXT-INDEX -input-file=%t.dir/index.txt %s -// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence ../llvm-"config"/../llvm-"cov"/native_separators.c -o %t.dir +// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S ../llvm-"config"/../llvm-"cov"/native_separators.c -o %t.dir // RUN: FileCheck -check-prefixes=HTML-INDEX -input-file=%t.dir/index.html %s -// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence %s -o %t.dir +// RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir // RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s // TEXT-INDEX: \tmp\native_separators.c Index: test/tools/llvm-cov/path_equivalence.c =================================================================== --- test/tools/llvm-cov/path_equivalence.c +++ test/tools/llvm-cov/path_equivalence.c @@ -0,0 +1,4 @@ +// RUN: llvm-profdata merge %S/Inputs/path_equivalence.proftext -o %t.profdata +// RUN: llvm-cov show %S/Inputs/path_equivalence.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S | FileCheck %s + +int main() {} // CHECK: [[@LINE]]| 1|int main() {} Index: test/tools/llvm-cov/prefer_used_to_unused.h =================================================================== --- test/tools/llvm-cov/prefer_used_to_unused.h +++ test/tools/llvm-cov/prefer_used_to_unused.h @@ -9,7 +9,7 @@ // llvm-cov convert-for-testing -o prefer_used_to_unused.covmapping tmp // RUN: llvm-profdata merge %S/Inputs/prefer_used_to_unused.proftext -o %t.profdata -// RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/uu/./,%S %s | FileCheck %s // Coverage data for this function has a non-zero hash value if it is used in the translation unit. inline int sampleFunc(int A) { // CHECK: [[@LINE]]| 1|inline int sampleFunc(int A) { Index: test/tools/llvm-cov/prevent_false_instantiations.h =================================================================== --- test/tools/llvm-cov/prevent_false_instantiations.h +++ test/tools/llvm-cov/prevent_false_instantiations.h @@ -4,7 +4,7 @@ // NAN-NOT: {{[ \t]+}}nan% // RUN: llvm-profdata merge %S/Inputs/prevent_false_instantiations.proftext -o %t.profdata -// RUN: llvm-cov show -format text %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -check-prefix=INSTANTIATION +// RUN: llvm-cov show -format text %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/false_instantiations/./,%S %s | FileCheck %s -check-prefix=INSTANTIATION // RUN: llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefix=NAN #define DO_SOMETHING() \ Index: test/tools/llvm-cov/report.cpp =================================================================== --- test/tools/llvm-cov/report.cpp +++ test/tools/llvm-cov/report.cpp @@ -1,6 +1,6 @@ -// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence 2>&1 | FileCheck %s -// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT %s -// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s +// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s +// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S %s 2>&1 | FileCheck -check-prefix=FILT %s +// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S %s does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s // CHECK: Regions Missed Regions Cover Functions Missed Functions Executed Instantiations Missed Insts. Executed Lines Missed Lines Cover // CHECK-NEXT: --- @@ -36,7 +36,7 @@ } // Test that listing multiple functions in a function view works. -// RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -filename-equivalence -name-regex=".*" %s +// RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -path-equivalence=/tmp,%S -name-regex=".*" %s // RUN: FileCheck -check-prefix=FUNCTIONS -input-file %t.dir/functions.txt %s // FUNCTIONS: _Z3foob // FUNCTIONS: _Z3barv Index: test/tools/llvm-cov/scan-directory.test =================================================================== --- test/tools/llvm-cov/scan-directory.test +++ test/tools/llvm-cov/scan-directory.test @@ -8,7 +8,8 @@ REAL-DAG: {{.*}}c.tmp REAL-DAG: {{.*}}d.tmp -RUN: llvm-cov show /dev/null -instr-profile /dev/null -dump-collected-paths -filename-equivalence %t a b c d e f | FileCheck %s --check-prefix=EQUIV +// NEEDS FIX. +RUN: llvm-cov show /dev/null -instr-profile /dev/null -dump-collected-paths -path-equivalence=/tmp,%S %t a b c d e f | FileCheck %s --check-prefix=EQUIV EQUIV-DAG: {{.*}}c.tmp EQUIV-DAG: {{.*}}d.tmp EQUIV-DAG: a Index: test/tools/llvm-cov/showExpansions.cpp =================================================================== --- test/tools/llvm-cov/showExpansions.cpp +++ test/tools/llvm-cov/showExpansions.cpp @@ -1,4 +1,4 @@ -// RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -filename-equivalence %s 2>&1 | FileCheck %s +// RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s #define DO_SOMETHING_ELSE() \ do { \ Index: test/tools/llvm-cov/showHighlightedRanges.cpp =================================================================== --- test/tools/llvm-cov/showHighlightedRanges.cpp +++ test/tools/llvm-cov/showHighlightedRanges.cpp @@ -1,4 +1,4 @@ -// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -filename-equivalence %s 2>&1 | FileCheck %s -check-prefixes=TEXT,SHARED +// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s -check-prefixes=TEXT,SHARED void func() { return; @@ -44,5 +44,5 @@ return 0; } -// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -filename-equivalence %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED +// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED // RUN: llvm-cov export %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata 2>&1 | FileCheck %S/Inputs/highlightedRanges.json Index: test/tools/llvm-cov/showLineExecutionCounts.cpp =================================================================== --- test/tools/llvm-cov/showLineExecutionCounts.cpp +++ test/tools/llvm-cov/showLineExecutionCounts.cpp @@ -26,12 +26,12 @@ // after coverage // WHOLE-FILE: [[@LINE]]| |// after // FILTER-NOT: [[@LINE-1]]| |// after -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence -name=main %s | FileCheck -check-prefixes=TEXT,FILTER %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s | FileCheck -check-prefixes=TEXT,FILTER %s // Test -output-dir. -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -filename-equivalence %s -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.dir -instr-profile %t.profdata -filename-equivalence -name=main %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.dir/functions.txt %s // @@ -40,8 +40,8 @@ // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())" // // Test html output. -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence %s -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence -name=main %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.dir/functions.html %s // Index: test/tools/llvm-cov/showProjectSummary.cpp =================================================================== --- test/tools/llvm-cov/showProjectSummary.cpp +++ test/tools/llvm-cov/showProjectSummary.cpp @@ -12,17 +12,17 @@ } // Test console output. -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,TEXT-FILE,TEXT-HEADER %S/Inputs/showProjectSummary.test -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER %S/Inputs/showProjectSummary.test -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -filename-equivalence %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER %S/Inputs/showProjectSummary.test -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile=%t.profdata -o %t.dir -filename-equivalence %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT,TEXT-FILE,TEXT-HEADER %S/Inputs/showProjectSummary.test +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER %S/Inputs/showProjectSummary.test +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER %S/Inputs/showProjectSummary.test +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile=%t.profdata -o %t.dir -path-equivalence=/tmp,%S %s // RUN: FileCheck -check-prefixes=TEXT-FOOTER -input-file=%t.dir/index.txt %S/Inputs/showProjectSummary.test // Test html output. -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -filename-equivalence %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s // RUN: FileCheck -check-prefixes=HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %S/Inputs/showProjectSummary.test -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -path-equivalence=/tmp,%S %s // RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %S/Inputs/showProjectSummary.test // RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FOOTER -input-file %t.dir/index.html %S/Inputs/showProjectSummary.test -// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence -name=main %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -path-equivalence=/tmp,%S -name=main %s // RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER -input-file %t.dir/functions.html %S/Inputs/showProjectSummary.test Index: test/tools/llvm-cov/showRegionMarkers.cpp =================================================================== --- test/tools/llvm-cov/showRegionMarkers.cpp +++ test/tools/llvm-cov/showRegionMarkers.cpp @@ -22,6 +22,6 @@ return 0; } -// RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -dump -filename-equivalence %s 2>&1 | FileCheck %s +// RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s // RUN: llvm-cov export %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata 2>&1 | FileCheck %S/Inputs/regionMarkers.json Index: test/tools/llvm-cov/showTabsHTML.cpp =================================================================== --- test/tools/llvm-cov/showTabsHTML.cpp +++ test/tools/llvm-cov/showTabsHTML.cpp @@ -1,5 +1,5 @@ // RUN: llvm-profdata merge -o %t.profdata %S/Inputs/showTabsHTML.proftext -// RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s +// RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s int main(int argc, char ** argv) { (void) "This tab starts at column 0"; // CHECK:   (void) "This tab starts at column 0"; @@ -9,7 +9,7 @@ return 0; } -// RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -tab-size=3 -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefix=CHECK-TABSIZE %s +// RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -tab-size=3 -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=CHECK-TABSIZE %s // CHECK-TABSIZE:    (void) "This tab starts at column 0"; // CHECK-TABSIZE: (void) "  This tab starts at column 10"; Index: test/tools/llvm-cov/showTemplateInstantiations.cpp =================================================================== --- test/tools/llvm-cov/showTemplateInstantiations.cpp +++ test/tools/llvm-cov/showTemplateInstantiations.cpp @@ -1,5 +1,5 @@ -// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %s | FileCheck -check-prefixes=SHARED,ALL %s -// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence -name=_Z4funcIbEiT_ %s | FileCheck -check-prefixes=SHARED,FILTER %s +// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=SHARED,ALL %s +// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S -name=_Z4funcIbEiT_ %s | FileCheck -check-prefixes=SHARED,FILTER %s // before coverage // ALL: [[@LINE]]| |// before // FILTER-NOT:[[@LINE-1]]| |// before @@ -40,8 +40,8 @@ // FILTER-NOT:[[@LINE-1]]| |// after // Test html output. -// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %s -format html -o %t.html.dir -// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence -name=_Z4funcIbEiT_ %s -format html -o %t.html.dir +// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %s -format html -o %t.html.dir +// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S -name=_Z4funcIbEiT_ %s -format html -o %t.html.dir // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-ALL -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-FILTER -input-file=%t.html.dir/functions.html %s Index: test/tools/llvm-cov/style.test =================================================================== --- test/tools/llvm-cov/style.test +++ test/tools/llvm-cov/style.test @@ -1,8 +1,8 @@ -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %S/showTemplateInstantiations.cpp -format html -o %t.dir +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp -format html -o %t.dir -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence -name=_Z4funcIbEiT_ %S/showTemplateInstantiations.cpp -format html -o %t.dir +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S -name=_Z4funcIbEiT_ %S/showTemplateInstantiations.cpp -format html -o %t.dir -RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %S/showTemplateInstantiations.cpp -format html | FileCheck %s -check-prefix=NODIR +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp -format html | FileCheck %s -check-prefix=NODIR RUN: FileCheck %s -input-file=%t.dir/style.css -check-prefix=STYLE RUN: FileCheck %s -input-file=%t.dir/functions.html -check-prefix=TOPLEVEL Index: test/tools/llvm-cov/threads.c =================================================================== --- test/tools/llvm-cov/threads.c +++ test/tools/llvm-cov/threads.c @@ -1,9 +1,9 @@ // Coverage/profile data recycled from the showLineExecutionCounts.cpp test. // // RUN: llvm-profdata merge %S/Inputs/lineExecutionCounts.proftext -o %t.profdata -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -j 1 -o %t1.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -num-threads 2 -o %t2.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp -// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t3.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -j 1 -o %t1.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showLineExecutionCounts.cpp +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -num-threads 2 -o %t2.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showLineExecutionCounts.cpp +// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t3.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showLineExecutionCounts.cpp // // RUN: diff %t1.dir/index.txt %t2.dir/index.txt // RUN: diff %t1.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %t2.dir/coverage/tmp/showLineExecutionCounts.cpp.txt Index: test/tools/llvm-cov/universal-binary.c =================================================================== --- test/tools/llvm-cov/universal-binary.c +++ test/tools/llvm-cov/universal-binary.c @@ -4,14 +4,14 @@ int main(int argc, const char *argv[]) {} // RUN: llvm-profdata merge %S/Inputs/universal-binary.proftext -o %t.profdata -// RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch x86_64 | FileCheck %s +// RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch x86_64 | FileCheck %s // RUN: llvm-cov export %S/Inputs/universal-binary -instr-profile %t.profdata -arch x86_64 2>&1 | FileCheck %S/Inputs/universal-binary.json // RUN: llvm-cov report %S/Inputs/universal-binary -arch x86_64 -object %S/Inputs/templateInstantiations.covmapping -arch i386 -instr-profile %t.profdata 2>&1 | FileCheck %s --check-prefix=COMBINED // COMBINED: showTemplateInstantiations.cpp // COMBINED-NEXT: universal-binary.c -// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch i386 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s +// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch i386 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s // WRONG-ARCH: Failed to load coverage // RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch definitly_a_made_up_architecture 2>&1 | FileCheck --check-prefix=MADE-UP-ARCH %s Index: test/tools/llvm-cov/warnings.h =================================================================== --- test/tools/llvm-cov/warnings.h +++ test/tools/llvm-cov/warnings.h @@ -1,13 +1,13 @@ -// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence /dev/null | FileCheck %s -allow-empty -check-prefix=FAKE-FILE-STDOUT -// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence /dev/null 2>&1 | FileCheck %s -check-prefix=FAKE-FILE-STDERR +// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S /dev/null | FileCheck %s -allow-empty -check-prefix=FAKE-FILE-STDOUT +// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S /dev/null 2>&1 | FileCheck %s -check-prefix=FAKE-FILE-STDERR // RUN: not llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html // RUN: not llvm-cov export %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html // FAKE-FILE-STDOUT-NOT: warning: The file '{{.*}}' isn't covered. // FAKE-FILE-STDERR: warning: The file '{{.*}}' isn't covered. -// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence -name ".*" /dev/null | FileCheck %s -allow-empty -check-prefix=FAKE-FUNC-STDOUT -// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence -name-regex ".*" /dev/null 2>&1 | FileCheck %s -check-prefix=FAKE-FUNC-STDERR +// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S -name ".*" /dev/null | FileCheck %s -allow-empty -check-prefix=FAKE-FUNC-STDOUT +// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/tmp,%S -name-regex ".*" /dev/null 2>&1 | FileCheck %s -check-prefix=FAKE-FUNC-STDERR // FAKE-FUNC-STDOUT-NOT: warning: Could not read coverage for '{{.*}}'. // FAKE-FUNC-STDERR: Could not read coverage for '{{.*}}'. Index: tools/llvm-cov/CodeCoverage.cpp =================================================================== --- tools/llvm-cov/CodeCoverage.cpp +++ tools/llvm-cov/CodeCoverage.cpp @@ -125,13 +125,14 @@ /// A list of input source files. std::vector SourceFiles; - /// Whether or not we're in -filename-equivalence mode. - bool CompareFilenamesOnly; - - /// In -filename-equivalence mode, this maps absolute paths from the + /// In -path-equivalence mode, this maps absolute paths from the /// coverage mapping data to input source files. StringMap RemappedFilenames; + /// The coverage data path to be remapped from, and the source path to be + /// remapped to, when using -path-equivalence. + Optional> PathRemapping; + /// The architecture the coverage mapping data targets. std::vector CoverageArches; @@ -171,27 +172,20 @@ } void CodeCoverageTool::addCollectedPath(const std::string &Path) { - if (CompareFilenamesOnly) { - SourceFiles.emplace_back(Path); - } else { - SmallString<128> EffectivePath(Path); - if (std::error_code EC = sys::fs::make_absolute(EffectivePath)) { - error(EC.message(), Path); - return; - } - sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true); - SourceFiles.emplace_back(EffectivePath.str()); + SmallString<128> EffectivePath(Path); + if (std::error_code EC = sys::fs::make_absolute(EffectivePath)) { + error(EC.message(), Path); + return; } + sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true); + SourceFiles.emplace_back(EffectivePath.str()); } void CodeCoverageTool::collectPaths(const std::string &Path) { llvm::sys::fs::file_status Status; llvm::sys::fs::status(Path, Status); if (!llvm::sys::fs::exists(Status)) { - if (CompareFilenamesOnly) - addCollectedPath(Path); - else - error("Missing source file", Path); + error("Missing source file", Path); return; } @@ -360,29 +354,19 @@ std::vector CoveredFiles = Coverage.getUniqueSourceFiles(); auto UncoveredFilesIt = SourceFiles.end(); - if (!CompareFilenamesOnly) { - // The user may have specified source files which aren't in the coverage - // mapping. Filter these files away. - UncoveredFilesIt = std::remove_if( - SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) { - return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(), - SF); - }); - } else { - for (auto &SF : SourceFiles) { - StringRef SFBase = sys::path::filename(SF); - for (const auto &CF : CoveredFiles) { - if (SFBase == sys::path::filename(CF)) { - RemappedFilenames[CF] = SF; - SF = CF; - break; - } + for (auto &SF : SourceFiles) { + StringRef SFBase = sys::path::filename(SF); + for (const auto &CF : CoveredFiles) { + if (SFBase == sys::path::filename(CF)) { + RemappedFilenames[CF] = SF; + SF = CF; + break; } } - UncoveredFilesIt = std::remove_if( - SourceFiles.begin(), SourceFiles.end(), - [&](const std::string &SF) { return !RemappedFilenames.count(SF); }); } + UncoveredFilesIt = std::remove_if( + SourceFiles.begin(), SourceFiles.end(), + [&](const std::string &SF) { return !RemappedFilenames.count(SF); }); SourceFiles.erase(UncoveredFilesIt, SourceFiles.end()); } @@ -521,10 +505,10 @@ "HTML output")), cl::init(CoverageViewOptions::OutputFormat::Text)); - cl::opt FilenameEquivalence( - "filename-equivalence", cl::Optional, - cl::desc("Treat source files as equivalent to paths in the coverage data " - "when the file names match, even if the full paths do not")); + cl::opt PathRemap( + "path-equivalence", cl::Optional, + cl::desc(", Map coverage data paths to local source file " + "paths")); cl::OptionCategory FilteringCategory("Function filtering options"); @@ -573,7 +557,6 @@ auto commandLineParser = [&, this](int argc, const char **argv) -> int { cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); ViewOpts.Debug = DebugDump; - CompareFilenamesOnly = FilenameEquivalence; if (!CovFilename.empty()) ObjectFilenames.emplace_back(CovFilename); @@ -598,6 +581,12 @@ break; } + // If path-equivalence was given and is a comma seperated pair then set + // PathRemapping. + auto EquivPair = StringRef(PathRemap).split(','); + if (!(EquivPair.first.empty() || EquivPair.second.empty())) + PathRemapping = EquivPair; + // If a demangler is supplied, check if it exists and register it. if (DemanglerOpts.size()) { auto DemanglerPathOrErr = sys::findProgramByName(DemanglerOpts[0]); @@ -804,6 +793,29 @@ for (StringRef Filename : Coverage->getUniqueSourceFiles()) SourceFiles.push_back(Filename); + // Remap by leading path (path-equivalence). + if (PathRemapping.hasValue()) { + // Convert to remapping paths to native paths with trailing seperators. + auto nativeWithTrailing = [](StringRef path) -> std::string { + SmallString<128> NativePath; + sys::path::native(path, NativePath); + if (!sys::path::is_separator(NativePath.back())) + NativePath += sys::path::get_separator(); + return NativePath.c_str(); + }; + std::string RemapFrom = nativeWithTrailing(PathRemapping->first); + std::string RemapTo = nativeWithTrailing(PathRemapping->second); + + for (StringRef Filename : SourceFiles) { + SmallString<128> NativeFilename; + sys::path::native(Filename, NativeFilename); + if (NativeFilename.startswith(RemapFrom)) { + RemappedFilenames[Filename] = + RemapTo + NativeFilename.substr(RemapFrom.size()).str(); + } + } + } + // Create an index out of the source files. if (ViewOpts.hasOutputDirectory()) { if (Error E = Printer->createIndexFile(SourceFiles, *Coverage)) {