llvm.org GIT mirror llvm / 8574d59
[llvm-cov] Add an option which maps the location of source directories on another machine to your local copies Summary: This patch adds the -path-equivalence option (example: llvm-cov show -path-equivalence=/origin/path,/local/path) which maps the source code path from one machine to another when using `llvm-cov show`. This is similar to the -filename-equivalence option, but doesn't require you to specify all the source files on the command line. This allows you to generate the coverage data on one machine (e.g. in a CI system), and then use llvm-cov on another machine where you have the same code base on a different path. Reviewers: vsk Reviewed By: vsk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36391 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310827 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Eveson 2 years ago
27 changed file(s) with 157 addition(s) and 105 deletion(s). Raw diff Collapse all Expand all
289289 Show code coverage only for functions with region coverage less than the given
290290 threshold.
291291
292 .. option:: -path-equivalence=,
293
294 Map the paths in the coverage data to local source file paths. This allows you
295 to generate the coverage data on one machine, and then use llvm-cov on a
296 different machine where you have the same files on a different path.
297
292298 .. program:: llvm-cov report
293299
294300 .. _llvm-cov-report:
0 main
1 # Func Hash:
2 0
3 # Num Counters:
4 1
5 # Counter Values:
6 1
7
33 int main(int argc, const char *argv[]) {}
44
55 // RUN: llvm-profdata merge %S/Inputs/binary-formats.proftext -o %t.profdata
6 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
7 // RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
8 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
6 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
7 // RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
8 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
99
1010 // RUN: llvm-cov export %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
1111 // RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
0 // Check that we combine expansion regions.
11
22 // RUN: llvm-profdata merge %S/Inputs/combine_expansions.proftext -o %t.profdata
3 // RUN: llvm-cov show %S/Inputs/combine_expansions.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
3 // RUN: llvm-cov show %S/Inputs/combine_expansions.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/ec,%S %s | FileCheck %s
44
55 #define SIMPLE_OP \
66 ++x
66 # of the same template function are properly merged in show
77 # output.
88
9 // 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
10 // 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
11 // 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
9 // 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
10 // RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux64l -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/root/llvm/test/tools,%S/.. %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h
11 // RUN: llvm-cov show %S/Inputs/binary-formats.v2.linux32l -instr-profile %S/Inputs/elf_binary_comdat.profdata -path-equivalence=/root/llvm/R/../test/tools,%S/.. %S/Inputs/instrprof-comdat.h | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h
None // RUN: llvm-cov show %S/Inputs/deferred-regions.covmapping -instr-profile %S/Inputs/deferred-regions.profdata -show-line-counts-or-regions -dump -filename-equivalence %s 2>&1 | FileCheck %s
0 // RUN: llvm-cov show %S/Inputs/deferred-regions.covmapping -instr-profile %S/Inputs/deferred-regions.profdata -show-line-counts-or-regions -dump -path-equivalence=/Users/vk/src/llvm.org-coverage-braces/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s
11
22 void foo(int x) {
33 if (x == 0) {
None 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
0 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
11
22 // Check that we demangle names even if the sub-view will be hidden.
33 RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata
4 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
4 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
55
66 // Check that we demangle names when printing out function summaries.
7 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
7 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
88
99 CHECK-DAG: XZ4funcIbEiTX
1010 CHECK-DAG: XZ4funcIiEiTX
0 RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata
11
2 RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck -check-prefix=FILE %s
2 RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp | FileCheck -check-prefix=FILE %s
33
4 RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -o %t.html.dir -filename-equivalence %S/showTemplateInstantiations.cpp
4 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
55 RUN: FileCheck -check-prefix=FILE %s -input-file %t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html
66
77 FILE: Unexecuted instantiation: _Z4funcIbEiT_
77 // RUN: llvm-profdata merge %S/Inputs/double_dots.proftext -o %t.profdata
88 // RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -o %t.dir
99 // RUN: FileCheck -check-prefixes=TEXT-INDEX -input-file=%t.dir/index.txt %s
10 // 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
10 // 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
1111 // RUN: FileCheck -check-prefixes=HTML-INDEX -input-file=%t.dir/index.html %s
12 // RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence %s -o %t.dir
12 // RUN: llvm-cov show -format=html %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S %s -o %t.dir
1313 // RUN: FileCheck -check-prefixes=HTML -input-file=%t.dir/coverage/tmp/native_separators.c.html %s
1414
1515 // TEXT-INDEX: \tmp\native_separators.c
0 // RUN: llvm-profdata merge %S/Inputs/path_equivalence.proftext -o %t.profdata
1 // RUN: llvm-cov show %S/Inputs/path_equivalence.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S | FileCheck %s
2
3 int main() {} // CHECK: [[@LINE]]| 1|int main() {}
88 // llvm-cov convert-for-testing -o prefer_used_to_unused.covmapping tmp
99
1010 // RUN: llvm-profdata merge %S/Inputs/prefer_used_to_unused.proftext -o %t.profdata
11 // RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
11 // RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/uu/./,%S %s | FileCheck %s
1212
1313 // Coverage data for this function has a non-zero hash value if it is used in the translation unit.
1414 inline int sampleFunc(int A) { // CHECK: [[@LINE]]| 1|inline int sampleFunc(int A) {
33 // NAN-NOT: {{[ \t]+}}nan%
44
55 // RUN: llvm-profdata merge %S/Inputs/prevent_false_instantiations.proftext -o %t.profdata
6 // RUN: llvm-cov show -format text %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s -check-prefix=INSTANTIATION
6 // 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
77 // RUN: llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefix=NAN
88
99 #define DO_SOMETHING() \
None // RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence 2>&1 | FileCheck %s
1 // 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
2 // 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
0 // RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S 2>&1 | FileCheck %s
1 // RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s 2>&1 | FileCheck -check-prefix=FILT %s
2 // RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
33
44 // CHECK: Regions Missed Regions Cover Functions Missed Functions Executed Instantiations Missed Insts. Executed Lines Missed Lines Cover
55 // CHECK-NEXT: ---
3535 }
3636
3737 // Test that listing multiple functions in a function view works.
38 // RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -filename-equivalence -name-regex=".*" %s
38 // RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -path-equivalence=,%S -name-regex=".*" %s
3939 // RUN: FileCheck -check-prefix=FUNCTIONS -input-file %t.dir/functions.txt %s
4040 // FUNCTIONS: _Z3foob
4141 // FUNCTIONS: _Z3barv
77 REAL-DAG: {{.*}}c.tmp
88 REAL-DAG: {{.*}}d.tmp
99
10 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
10 // NEEDS FIX.
11 RUN: llvm-cov show /dev/null -instr-profile /dev/null -dump-collected-paths -path-equivalence=%t,%S %t a b c d e f | FileCheck %s --check-prefix=EQUIV
1112 EQUIV-DAG: {{.*}}c.tmp
1213 EQUIV-DAG: {{.*}}d.tmp
1314 EQUIV-DAG: a
None // RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -filename-equivalence %s 2>&1 | FileCheck %s
0 // RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -path-equivalence="/Users/bogner/code/llvm/test/tools,%S/.." %s 2>&1 | FileCheck %s
11
22 #define DO_SOMETHING_ELSE() \
33 do { \
None // 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
0 // RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -path-equivalence=/Users/bogner/code/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s -check-prefixes=TEXT,SHARED
11
22 void func() {
33 return;
4343 return 0;
4444 }
4545
46 // 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
46 // RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -path-equivalence=/Users/bogner/code/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED
4747 // RUN: llvm-cov export %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata 2>&1 | FileCheck %S/Inputs/highlightedRanges.json
2525 // after coverage // WHOLE-FILE: [[@LINE]]| |// after
2626 // FILTER-NOT: [[@LINE-1]]| |// after
2727
28 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s
29 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence -name=main %s | FileCheck -check-prefixes=TEXT,FILTER %s
28 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s
29 // 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
3030
3131 // Test -output-dir.
32 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -filename-equivalence %s
33 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.dir -instr-profile %t.profdata -filename-equivalence -name=main %s
32 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s
33 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s
3434 // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s
3535 // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.dir/functions.txt %s
3636 //
3939 // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())"
4040 //
4141 // Test html output.
42 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence %s
43 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence -name=main %s
42 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s
43 // 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
4444 // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4545 // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.dir/functions.html %s
4646 //
1111 }
1212
1313 // Test console output.
14 // 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
15 // 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
16 // 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
17 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile=%t.profdata -o %t.dir -filename-equivalence %s
14 // 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
15 // 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
16 // 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
17 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile=%t.profdata -o %t.dir -path-equivalence=/tmp,%S %s
1818 // RUN: FileCheck -check-prefixes=TEXT-FOOTER -input-file=%t.dir/index.txt %S/Inputs/showProjectSummary.test
1919
2020 // Test html output.
21 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -filename-equivalence %s
21 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s
2222 // RUN: FileCheck -check-prefixes=HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %S/Inputs/showProjectSummary.test
23 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s
23 // 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
2424 // RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %S/Inputs/showProjectSummary.test
2525 // RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FOOTER -input-file %t.dir/index.html %S/Inputs/showProjectSummary.test
26 // 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
26 // 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
2727 // RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER -input-file %t.dir/functions.html %S/Inputs/showProjectSummary.test
2121 return 0;
2222 }
2323
24 // RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -dump -filename-equivalence %s 2>&1 | FileCheck %s
24 // RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata -show-regions -dump -path-equivalence=/Users/bogner/code/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s
2525
2626 // RUN: llvm-cov export %S/Inputs/regionMarkers.covmapping -instr-profile %t.profdata 2>&1 | FileCheck %S/Inputs/regionMarkers.json
0 // RUN: llvm-profdata merge -o %t.profdata %S/Inputs/showTabsHTML.proftext
1 // RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
1 // RUN: llvm-cov show %S/Inputs/showTabsHTML.covmapping -format html -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
22
33 int main(int argc, char ** argv) {
44 (void) "This tab starts at column 0"; // CHECK:   (void) "This tab starts at column 0";
88 return 0;
99 }
1010
11 // 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
11 // 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
1212
1313 // CHECK-TABSIZE:    (void) "This tab starts at column 0";
1414 // CHECK-TABSIZE: (void) "  This tab starts at column 10";
None // RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %s | FileCheck -check-prefixes=SHARED,ALL %s
1 // 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
0 // 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
1 // 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
22
33 // before coverage // ALL: [[@LINE]]| |// before
44 // FILTER-NOT:[[@LINE-1]]| |// before
3939 // FILTER-NOT:[[@LINE-1]]| |// after
4040
4141 // Test html output.
42 // RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %s -format html -o %t.html.dir
43 // 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
42 // 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
43 // 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
4444 // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-ALL -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
4545 // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-FILTER -input-file=%t.html.dir/functions.html %s
4646
8787 // HTML-JUMP:
Source (jump to first uncovered line)
8888 // HTML-JUMP-NOT:
Source (jump to first uncovered line)
8989
90 // RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -show-instantiations=false -filename-equivalence %s | FileCheck -check-prefix=NO_INSTS %s
90 // RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -show-instantiations=false -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=NO_INSTS %s
9191 // NO_INSTS-NOT: {{^ *}}| _Z4funcIbEiT_:
9292 // NO_INSTS-NOT: {{^ *}}| _Z4funcIiEiT_:
None RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -filename-equivalence %S/showTemplateInstantiations.cpp -format html -o %t.dir
0 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
11
2 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
2 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
33
4 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
4 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
55
66 RUN: FileCheck %s -input-file=%t.dir/style.css -check-prefix=STYLE
77 RUN: FileCheck %s -input-file=%t.dir/functions.html -check-prefix=TOPLEVEL
0 // Coverage/profile data recycled from the showLineExecutionCounts.cpp test.
11 //
22 // RUN: llvm-profdata merge %S/Inputs/lineExecutionCounts.proftext -o %t.profdata
3 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -j 1 -o %t1.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp
4 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -num-threads 2 -o %t2.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp
5 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t3.dir -instr-profile %t.profdata -filename-equivalence %S/showLineExecutionCounts.cpp
3 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -j 1 -o %t1.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showLineExecutionCounts.cpp
4 // 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
5 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t3.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %S/showLineExecutionCounts.cpp
66 //
77 // RUN: diff %t1.dir/index.txt %t2.dir/index.txt
88 // RUN: diff %t1.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %t2.dir/coverage/tmp/showLineExecutionCounts.cpp.txt
33 int main(int argc, const char *argv[]) {}
44
55 // RUN: llvm-profdata merge %S/Inputs/universal-binary.proftext -o %t.profdata
6 // RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch x86_64 | FileCheck %s
6 // RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch x86_64 | FileCheck %s
77 // RUN: llvm-cov export %S/Inputs/universal-binary -instr-profile %t.profdata -arch x86_64 2>&1 | FileCheck %S/Inputs/universal-binary.json
88
99 // 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
1010 // COMBINED: showTemplateInstantiations.cpp
1111 // COMBINED-NEXT: universal-binary.c
1212
13 // 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
13 // 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
1414 // WRONG-ARCH: Failed to load coverage
1515
16 // 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
16 // RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch definitly_a_made_up_architecture 2>&1 | FileCheck --check-prefix=MADE-UP-ARCH %s
1717 // MADE-UP-ARCH: Unknown architecture: definitly_a_made_up_architecture
1818
19 // RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch=x86_64 -arch=x86_64 2>&1 | FileCheck --check-prefix=TOO-MANY-ARCH %s
19 // RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch=x86_64 -arch=x86_64 2>&1 | FileCheck --check-prefix=TOO-MANY-ARCH %s
2020 // TOO-MANY-ARCH: Number of architectures doesn't match the number of objects
2121 //
2222 // RUN: not llvm-cov report -instr-profile %t.profdata 2>&1 | FileCheck --check-prefix=MISSING-BINARY %s
None // 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
1 // 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
0 // 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
1 // 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
22 // RUN: not llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html
33 // RUN: not llvm-cov export %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html
44
55 // FAKE-FILE-STDOUT-NOT: warning: The file '{{.*}}' isn't covered.
66 // FAKE-FILE-STDERR: warning: The file '{{.*}}' isn't covered.
77
8 // 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
9 // 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
8 // 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
9 // 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
1010
1111 // FAKE-FUNC-STDOUT-NOT: warning: Could not read coverage for '{{.*}}'.
1212 // FAKE-FUNC-STDERR: Could not read coverage for '{{.*}}'.
9393 /// \brief Load the coverage mapping data. Return nullptr if an error occurred.
9494 std::unique_ptr load();
9595
96 /// \brief Create a mapping from files in the Coverage data to local copies
97 /// (path-equivalence).
98 void remapPathNames(const CoverageMapping &Coverage);
99
96100 /// \brief Remove input source files which aren't mapped by \p Coverage.
97101 void removeUnmappedInputs(const CoverageMapping &Coverage);
98102
124128 /// A list of input source files.
125129 std::vector SourceFiles;
126130
127 /// Whether or not we're in -filename-equivalence mode.
128 bool CompareFilenamesOnly;
129
130 /// In -filename-equivalence mode, this maps absolute paths from the
131 /// coverage mapping data to input source files.
131 /// In -path-equivalence mode, this maps the absolute paths from the coverage
132 /// mapping data to the input source files.
132133 StringMap RemappedFilenames;
134
135 /// The coverage data path to be remapped from, and the source path to be
136 /// remapped to, when using -path-equivalence.
137 Optional> PathRemapping;
133138
134139 /// The architecture the coverage mapping data targets.
135140 std::vector CoverageArches;
170175 }
171176
172177 void CodeCoverageTool::addCollectedPath(const std::string &Path) {
173 if (CompareFilenamesOnly) {
174 SourceFiles.emplace_back(Path);
175 } else {
176 SmallString<128> EffectivePath(Path);
177 if (std::error_code EC = sys::fs::make_absolute(EffectivePath)) {
178 error(EC.message(), Path);
179 return;
180 }
181 sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true);
182 SourceFiles.emplace_back(EffectivePath.str());
183 }
178 SmallString<128> EffectivePath(Path);
179 if (std::error_code EC = sys::fs::make_absolute(EffectivePath)) {
180 error(EC.message(), Path);
181 return;
182 }
183 sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true);
184 SourceFiles.emplace_back(EffectivePath.str());
184185 }
185186
186187 void CodeCoverageTool::collectPaths(const std::string &Path) {
187188 llvm::sys::fs::file_status Status;
188189 llvm::sys::fs::status(Path, Status);
189190 if (!llvm::sys::fs::exists(Status)) {
190 if (CompareFilenamesOnly)
191 if (PathRemapping)
191192 addCollectedPath(Path);
192193 else
193194 error("Missing source file", Path);
347348 if (Mismatched)
348349 warning(utostr(Mismatched) + " functions have mismatched data");
349350
351 remapPathNames(*Coverage);
352
350353 if (!SourceFiles.empty())
351354 removeUnmappedInputs(*Coverage);
352355
355358 return Coverage;
356359 }
357360
361 void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) {
362 if (!PathRemapping)
363 return;
364
365 // Convert remapping paths to native paths with trailing seperators.
366 auto nativeWithTrailing = [](StringRef Path) -> std::string {
367 if (Path.empty())
368 return "";
369 SmallString<128> NativePath;
370 sys::path::native(Path, NativePath);
371 if (!sys::path::is_separator(NativePath.back()))
372 NativePath += sys::path::get_separator();
373 return NativePath.c_str();
374 };
375 std::string RemapFrom = nativeWithTrailing(PathRemapping->first);
376 std::string RemapTo = nativeWithTrailing(PathRemapping->second);
377
378 // Create a mapping from coverage data file paths to local paths.
379 for (StringRef Filename : Coverage.getUniqueSourceFiles()) {
380 SmallString<128> NativeFilename;
381 sys::path::native(Filename, NativeFilename);
382 if (NativeFilename.startswith(RemapFrom)) {
383 RemappedFilenames[Filename] =
384 RemapTo + NativeFilename.substr(RemapFrom.size()).str();
385 }
386 }
387
388 // Convert input files from local paths to coverage data file paths.
389 StringMap InvRemappedFilenames;
390 for (const auto &RemappedFilename : RemappedFilenames)
391 InvRemappedFilenames[RemappedFilename.getValue()] = RemappedFilename.getKey();
392
393 for (std::string &Filename : SourceFiles) {
394 SmallString<128> NativeFilename;
395 sys::path::native(Filename, NativeFilename);
396 auto CovFileName = InvRemappedFilenames.find(NativeFilename);
397 if (CovFileName != InvRemappedFilenames.end())
398 Filename = CovFileName->second;
399 }
400 }
401
358402 void CodeCoverageTool::removeUnmappedInputs(const CoverageMapping &Coverage) {
359403 std::vector CoveredFiles = Coverage.getUniqueSourceFiles();
360404
361405 auto UncoveredFilesIt = SourceFiles.end();
362 if (!CompareFilenamesOnly) {
363 // The user may have specified source files which aren't in the coverage
364 // mapping. Filter these files away.
365 UncoveredFilesIt = std::remove_if(
366 SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) {
367 return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(),
368 SF);
369 });
370 } else {
371 for (auto &SF : SourceFiles) {
372 StringRef SFBase = sys::path::filename(SF);
373 for (const auto &CF : CoveredFiles) {
374 if (SFBase == sys::path::filename(CF)) {
375 RemappedFilenames[CF] = SF;
376 SF = CF;
377 break;
378 }
379 }
380 }
381 UncoveredFilesIt = std::remove_if(
382 SourceFiles.begin(), SourceFiles.end(),
383 [&](const std::string &SF) { return !RemappedFilenames.count(SF); });
384 }
406 // The user may have specified source files which aren't in the coverage
407 // mapping. Filter these files away.
408 UncoveredFilesIt = std::remove_if(
409 SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) {
410 return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(),
411 SF);
412 });
385413
386414 SourceFiles.erase(UncoveredFilesIt, SourceFiles.end());
387415 }
520548 "HTML output")),
521549 cl::init(CoverageViewOptions::OutputFormat::Text));
522550
523 cl::opt FilenameEquivalence(
524 "filename-equivalence", cl::Optional,
525 cl::desc("Treat source files as equivalent to paths in the coverage data "
526 "when the file names match, even if the full paths do not"));
551 cl::opt PathRemap(
552 "path-equivalence", cl::Optional,
553 cl::desc(", Map coverage data paths to local source file "
554 "paths"));
527555
528556 cl::OptionCategory FilteringCategory("Function filtering options");
529557
572600 auto commandLineParser = [&, this](int argc, const char **argv) -> int {
573601 cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n");
574602 ViewOpts.Debug = DebugDump;
575 CompareFilenamesOnly = FilenameEquivalence;
576603
577604 if (!CovFilename.empty())
578605 ObjectFilenames.emplace_back(CovFilename);
596623 ViewOpts.Colors = true;
597624 break;
598625 }
626
627 // If path-equivalence was given and is a comma seperated pair then set
628 // PathRemapping.
629 auto EquivPair = StringRef(PathRemap).split(',');
630 if (!(EquivPair.first.empty() && EquivPair.second.empty()))
631 PathRemapping = EquivPair;
599632
600633 // If a demangler is supplied, check if it exists and register it.
601634 if (DemanglerOpts.size()) {