
Template functions share the same lines in source files, so the common container of lines' properties cannot be used to calculate the coverage statistics of individual functions. > cat tmpl.cpp template <int N> int test() { return N; } int main() { return test<1>() + test<2>(); } > clang++ --coverage tmpl.cpp -o tmpl > ./tmpl > llvm-cov gcov tmpl.cpp -f ... Function '_Z4testILi1EEiv' Lines executed:100.00% of 1 Function '_Z4testILi2EEiv' Lines executed:-nan% of 0 ... > llvm-cov-patched gcov tmpl.cpp -f ... Function '_Z4testILi1EEiv' Lines executed:100.00% of 1 Function '_Z4testILi2EEiv' Lines executed:100.00% of 1 ... Differential Revision: https://reviews.llvm.org/D121390
20 lines
566 B
Plaintext
20 lines
566 B
Plaintext
# Check that the coverage statistics for template functions are calculated as expected.
|
|
|
|
RUN: rm -rf %t
|
|
RUN: mkdir %t
|
|
RUN: cd %t
|
|
RUN: cp %p/Inputs/tmpl* .
|
|
|
|
RUN: llvm-cov gcov tmpl.cpp -f | FileCheck %s --check-prefix=F
|
|
RUN: llvm-cov gcov tmpl.cpp -t | FileCheck %s --check-prefix=T
|
|
|
|
F: Function '_Z4testILi1EEiv'
|
|
F-NEXT: Lines executed:100.00% of 1
|
|
F: Function '_Z4testILi2EEiv'
|
|
F-NEXT: Lines executed:100.00% of 1
|
|
|
|
T: -: 1:template <int N>
|
|
T-NEXT: 2: 2:int test() { return N; }
|
|
T-NEXT: -: 3:
|
|
T-NEXT: 1: 4:int main() { return test<1>() + test<2>(); }
|