Skip to content

Commit 0350c1e

Browse files
committed
Move mcdc-templates-merge.test from #121194
1 parent 8afb2ff commit 0350c1e

File tree

5 files changed

+264
-0
lines changed

5 files changed

+264
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <cstdio>
2+
3+
template <typename Ty>
4+
bool ab(Ty a, Ty b) {
5+
return (a && b);
6+
}
7+
// CHECK: [[@LINE-2]]| 4| return
8+
9+
// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00%
10+
// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00%
11+
// CHECK: MC/DC Coverage for Decision{{[:]}} 0.00%
12+
// CHECK-NOT: MC/DC Coverage for Decision{{[:]}}
13+
14+
// CHECK: _Z2abIbEbT_S0_{{[:]}}
15+
// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00%
16+
17+
// CHECK: _Z2abIxEbT_S0_{{[:]}}
18+
// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00%
19+
20+
// CHECK: Unexecuted instantiation{{[:]}} _Z2abIdEbT_S0_
21+
22+
template <bool C>
23+
bool Cab(bool a, bool b) {
24+
return (a && b && C);
25+
}
26+
// CHECK: [[@LINE-2]]| 4| return
27+
28+
// CHECK: MC/DC Coverage for Decision{{[:]}} 0.00%
29+
// CHECK: MC/DC Coverage for Decision{{[:]}} 50.00%
30+
// CHECK-NOT: MC/DC Coverage for Decision{{[:]}}
31+
32+
// CHECK: _Z3CabILb0EEbbb{{[:]}}
33+
// CHECK: | | MC/DC Coverage for Decision{{[:]}} 0.00%
34+
35+
// CHECK: _Z3CabILb1EEbbb{{[:]}}
36+
// CHECK: | | MC/DC Coverage for Decision{{[:]}} 50.00%
37+
38+
// CHECK: [[@LINE+1]]| 1|int main
39+
int main(int argc, char **argv) {
40+
printf("%d\n", Cab<false>(false, false));
41+
printf("%d\n", Cab<false>(true, true));
42+
printf("%d\n", Cab<true>(true, false));
43+
printf("%d\n", Cab<true>(true, true));
44+
printf("%d\n", ab(false, false));
45+
printf("%d\n", ab(true, true));
46+
printf("%d\n", ab(1LL, 0LL));
47+
printf("%d\n", ab(1LL, 1LL));
48+
if (argc == 2)
49+
printf("%d\n", ab(0.0, 0.0));
50+
return 0;
51+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
_Z2abIbEbT_S0_
2+
# Func Hash:
3+
1550
4+
# Num Counters:
5+
3
6+
# Counter Values:
7+
2
8+
1
9+
1
10+
# Num Bitmap Bytes:
11+
$1
12+
# Bitmap Byte Values:
13+
0x5
14+
15+
16+
_Z2abIxEbT_S0_
17+
# Func Hash:
18+
1550
19+
# Num Counters:
20+
3
21+
# Counter Values:
22+
2
23+
2
24+
1
25+
# Num Bitmap Bytes:
26+
$1
27+
# Bitmap Byte Values:
28+
0x6
29+
30+
31+
_Z3CabILb0EEbbb
32+
# Func Hash:
33+
99214
34+
# Num Counters:
35+
5
36+
# Counter Values:
37+
2
38+
1
39+
0
40+
1
41+
1
42+
# Num Bitmap Bytes:
43+
$1
44+
# Bitmap Byte Values:
45+
0x5
46+
47+
48+
_Z3CabILb1EEbbb
49+
# Func Hash:
50+
99214
51+
# Num Counters:
52+
5
53+
# Counter Values:
54+
2
55+
1
56+
1
57+
2
58+
1
59+
# Num Bitmap Bytes:
60+
$1
61+
# Bitmap Byte Values:
62+
0xa
63+
64+
65+
main
66+
# Func Hash:
67+
175973464
68+
# Num Counters:
69+
2
70+
# Counter Values:
71+
1
72+
0
73+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
--- !ELF
2+
FileHeader:
3+
Class: ELFCLASS64
4+
Data: ELFDATA2LSB
5+
OSABI: ELFOSABI_GNU
6+
Type: ET_REL
7+
Machine: EM_X86_64
8+
SectionHeaderStringTable: .strtab
9+
Sections:
10+
- Name: __llvm_covfun
11+
Type: SHT_PROGBITS
12+
Flags: [ SHF_GNU_RETAIN ]
13+
AddressAlign: 0x8
14+
Content: FAD58DE7366495DB2500000058247D0A00000000249EC986A505B62F0101010105050127210C020109070010200502000700100500110185808080080501050021
15+
- Name: '__llvm_covfun (1)'
16+
Type: SHT_PROGBITS
17+
Flags: [ SHF_GNU_RETAIN ]
18+
AddressAlign: 0x8
19+
Content: 9CC3B348501DBFE8480000008E83010000000000249EC986A505B62F010103010D0D1105090901171A020201010B000C01000B0011280403000B0016300D02010300000B000C0D0010001130110603020000100011050015001630000A02000000150016
20+
- Name: '__llvm_covfun (2)'
21+
Type: SHT_PROGBITS
22+
Flags: [ SHF_GNU_RETAIN ]
23+
AddressAlign: 0x8
24+
Content: 9873627177A03F8E460000008E83010000000000249EC986A505B62F010102010D0D110901171A020201010B000C01000B0011280403000B0016300D02010300000B000C0D0010001130110603020000100011050015001630090002000000150016
25+
- Name: '__llvm_covfun (3)'
26+
Type: SHT_PROGBITS
27+
Flags: [ SHF_GNU_RETAIN ]
28+
AddressAlign: 0x8
29+
Content: BF407A207503B266320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011
30+
- Name: '__llvm_covfun (4)'
31+
Type: SHT_PROGBITS
32+
Flags: [ SHF_GNU_RETAIN ]
33+
AddressAlign: 0x8
34+
Content: 8A05A22CB467C37D320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011
35+
- Name: '__llvm_covfun (5)'
36+
Type: SHT_PROGBITS
37+
Flags: [ SHF_GNU_RETAIN ]
38+
AddressAlign: 0x8
39+
Content: 1700192CAC8F3F26320000000E06000000000000249EC986A505B62F0101020105050906010415020201010B000C280302000B0011300502010200000B000C050010001130090602000000100011
40+
- Name: __llvm_covmap
41+
Type: SHT_PROGBITS
42+
Flags: [ SHF_GNU_RETAIN ]
43+
AddressAlign: 0x8
44+
Content: 000000001D0000000000000006000000021A0000186D6364632D74656D706C617465732D6D657267652E637070000000
45+
- Name: __llvm_prf_names
46+
Type: SHT_PROGBITS
47+
Flags: [ SHF_ALLOC, SHF_GNU_RETAIN ]
48+
AddressAlign: 0x1
49+
Content: 51006D61696E015F5A33436162494C62304545626262015F5A33436162494C62314545626262015F5A32616249624562545F53305F015F5A32616249784562545F53305F015F5A32616249644562545F53305F
50+
- Type: SectionHeaderTable
51+
Sections:
52+
- Name: .strtab
53+
- Name: __llvm_covfun
54+
- Name: '__llvm_covfun (1)'
55+
- Name: '__llvm_covfun (2)'
56+
- Name: '__llvm_covfun (3)'
57+
- Name: '__llvm_covfun (4)'
58+
- Name: '__llvm_covfun (5)'
59+
- Name: __llvm_covmap
60+
- Name: __llvm_prf_names
61+
- Name: .symtab
62+
Symbols:
63+
- Name: __llvm_covmap
64+
Type: STT_SECTION
65+
Section: __llvm_covmap
66+
- Name: __llvm_prf_names
67+
Type: STT_SECTION
68+
Section: __llvm_prf_names
69+
- Name: __covrec_DB956436E78DD5FAu
70+
Type: STT_OBJECT
71+
Section: __llvm_covfun
72+
Binding: STB_WEAK
73+
Size: 0x41
74+
Other: [ STV_HIDDEN ]
75+
- Name: __covrec_E8BF1D5048B3C39Cu
76+
Type: STT_OBJECT
77+
Section: '__llvm_covfun (1)'
78+
Binding: STB_WEAK
79+
Size: 0x64
80+
Other: [ STV_HIDDEN ]
81+
- Name: __covrec_8E3FA07771627398u
82+
Type: STT_OBJECT
83+
Section: '__llvm_covfun (2)'
84+
Binding: STB_WEAK
85+
Size: 0x62
86+
Other: [ STV_HIDDEN ]
87+
- Name: __covrec_66B20375207A40BFu
88+
Type: STT_OBJECT
89+
Section: '__llvm_covfun (3)'
90+
Binding: STB_WEAK
91+
Size: 0x4E
92+
Other: [ STV_HIDDEN ]
93+
- Name: __covrec_7DC367B42CA2058Au
94+
Type: STT_OBJECT
95+
Section: '__llvm_covfun (4)'
96+
Binding: STB_WEAK
97+
Size: 0x4E
98+
Other: [ STV_HIDDEN ]
99+
- Name: __covrec_263F8FAC2C190017u
100+
Type: STT_OBJECT
101+
Section: '__llvm_covfun (5)'
102+
Binding: STB_WEAK
103+
Size: 0x4E
104+
Other: [ STV_HIDDEN ]
105+
...

llvm/test/tools/llvm-cov/branch-macros.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: llvm-profdata merge %S/Inputs/branch-macros.proftext -o %t.profdata
22
// RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=999
3+
// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/branch-macros.cpp | FileCheck %s -check-prefix=FILE
4+
35
// RUN: llvm-cov show --binary-counters --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=1
46
// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S/Inputs %S/Inputs/branch-macros.cpp | FileCheck %s -check-prefix=REPORT
57

@@ -14,3 +16,9 @@
1416
// REPORT-NEXT: main 1 0 100.00% 6 0 100.00% 0 0 0.00%
1517
// REPORT-NEXT: ---
1618
// REPORT-NEXT: TOTAL 16 4 75.00% 32 0 100.00% 40 16 60.00%
19+
20+
// FILE: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
21+
// FILE-NEXT: ---
22+
// FILE-NEXT: branch-macros.cpp 16 4 75.00% 3 0 100.00% 32 0 100.00% 40 16 60.00%
23+
// FILE-NEXT: ---
24+
// FILE-NEXT: TOTAL 16 4 75.00% 3 0 100.00% 32 0 100.00% 40 16 60.00%
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Test `merge-instantiations=merge/any/all`
2+
3+
RUN: yaml2obj %S/Inputs/mcdc-templates-merge.yaml -o %t.o
4+
RUN: llvm-profdata merge %S/Inputs/mcdc-templates-merge.proftext -o %t.profdata
5+
6+
RUN: llvm-cov show --show-mcdc -show-instantiations=true %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %S/Inputs/mcdc-templates-merge.cpp
7+
8+
RUN: llvm-cov report --show-mcdc-summary %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s
9+
10+
REPORT: mcdc-templates-merge.cpp
11+
12+
# Regions
13+
CHECK: 10 1 90.00%
14+
15+
# Functions
16+
CHECK: 3 0 100.00%
17+
18+
# Lines
19+
CHECK: 19 1 94.74%
20+
21+
# Branches
22+
CHECK: 11 3 72.73%
23+
24+
# MC/DC Conditions
25+
CHECK: 4 2 50.00%
26+
27+
REPORT: TOTAL

0 commit comments

Comments
 (0)