Skip to content

Commit 4a011ac

Browse files
authored
[Coverage] Introduce "partial fold" on BranchRegion (#112694)
Currently both True/False counts were folded. It lost the information, "It is True or False before folding." It prevented recalling branch counts in merging template instantiations. In `llvm-cov`, a folded branch is shown as: - `[True: n, Folded]` - `[Folded, False n]` In the case If `n` is zero, a branch is reported as "uncovered". This is distinguished from "folded" branch. When folded branches are merged, `Folded` may be dissolved. In the coverage map, either `Counter` is `Zero`. Currently both were `Zero`. Since "partial fold" has been introduced, either case in `switch` is omitted as `Folded`. Each `case:` in `switch` is reported as `[True: n, Folded]`, since `False` count doesn't show meaningful value. When `switch` doesn't have `default:`, `switch (Cond)` is reported as `[Folded, False: n]`, since `True` count was just the sum of `case`(s). `switch` with `default` can be considered as "the statement that doesn't have any `False`(s)".
1 parent 1336e3d commit 4a011ac

16 files changed

+169
-164
lines changed

Diff for: clang/lib/CodeGen/CoverageMappingGen.cpp

+17-29
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,6 @@ struct CounterCoverageMappingBuilder
10981098
return ExitCount;
10991099
}
11001100

1101-
/// Determine whether the given condition can be constant folded.
1102-
bool ConditionFoldsToBool(const Expr *Cond) {
1103-
Expr::EvalResult Result;
1104-
return (Cond->EvaluateAsInt(Result, CVM.getCodeGenModule().getContext()));
1105-
}
1106-
11071101
/// Create a Branch Region around an instrumentable condition for coverage
11081102
/// and add it to the function's SourceRegions. A branch region tracks a
11091103
/// "True" counter and a "False" counter for boolean expressions that
@@ -1133,13 +1127,15 @@ struct CounterCoverageMappingBuilder
11331127
// Alternatively, we can prevent any optimization done via
11341128
// constant-folding by ensuring that ConstantFoldsToSimpleInteger() in
11351129
// CodeGenFunction.c always returns false, but that is very heavy-handed.
1136-
if (ConditionFoldsToBool(C))
1137-
popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C),
1138-
Counter::getZero(), BranchParams));
1139-
else
1140-
// Otherwise, create a region with the True counter and False counter.
1141-
popRegions(pushRegion(TrueCnt, getStart(C), getEnd(C), FalseCnt,
1142-
BranchParams));
1130+
Expr::EvalResult Result;
1131+
if (C->EvaluateAsInt(Result, CVM.getCodeGenModule().getContext())) {
1132+
if (Result.Val.getInt().getBoolValue())
1133+
FalseCnt = Counter::getZero();
1134+
else
1135+
TrueCnt = Counter::getZero();
1136+
}
1137+
popRegions(
1138+
pushRegion(TrueCnt, getStart(C), getEnd(C), FalseCnt, BranchParams));
11431139
}
11441140
}
11451141

@@ -1153,12 +1149,12 @@ struct CounterCoverageMappingBuilder
11531149

11541150
/// Create a Branch Region around a SwitchCase for code coverage
11551151
/// and add it to the function's SourceRegions.
1156-
void createSwitchCaseRegion(const SwitchCase *SC, Counter TrueCnt,
1157-
Counter FalseCnt) {
1152+
void createSwitchCaseRegion(const SwitchCase *SC, Counter TrueCnt) {
11581153
// Push region onto RegionStack but immediately pop it (which adds it to
11591154
// the function's SourceRegions) because it doesn't apply to any other
11601155
// source other than the SwitchCase.
1161-
popRegions(pushRegion(TrueCnt, getStart(SC), SC->getColonLoc(), FalseCnt));
1156+
popRegions(pushRegion(TrueCnt, getStart(SC), SC->getColonLoc(),
1157+
Counter::getZero()));
11621158
}
11631159

11641160
/// Check whether a region with bounds \c StartLoc and \c EndLoc
@@ -1870,24 +1866,16 @@ struct CounterCoverageMappingBuilder
18701866
const SwitchCase *Case = S->getSwitchCaseList();
18711867
for (; Case; Case = Case->getNextSwitchCase()) {
18721868
HasDefaultCase = HasDefaultCase || isa<DefaultStmt>(Case);
1873-
CaseCountSum =
1874-
addCounters(CaseCountSum, getRegionCounter(Case), /*Simplify=*/false);
1875-
createSwitchCaseRegion(
1876-
Case, getRegionCounter(Case),
1877-
subtractCounters(ParentCount, getRegionCounter(Case)));
1869+
auto CaseCount = getRegionCounter(Case);
1870+
CaseCountSum = addCounters(CaseCountSum, CaseCount, /*Simplify=*/false);
1871+
createSwitchCaseRegion(Case, CaseCount);
18781872
}
1879-
// Simplify is skipped while building the counters above: it can get really
1880-
// slow on top of switches with thousands of cases. Instead, trigger
1881-
// simplification by adding zero to the last counter.
1882-
CaseCountSum = addCounters(CaseCountSum, Counter::getZero());
1883-
18841873
// If no explicit default case exists, create a branch region to represent
18851874
// the hidden branch, which will be added later by the CodeGen. This region
18861875
// will be associated with the switch statement's condition.
18871876
if (!HasDefaultCase) {
1888-
Counter DefaultTrue = subtractCounters(ParentCount, CaseCountSum);
1889-
Counter DefaultFalse = subtractCounters(ParentCount, DefaultTrue);
1890-
createBranchRegion(S->getCond(), DefaultTrue, DefaultFalse);
1877+
Counter DefaultCount = subtractCounters(ParentCount, CaseCountSum);
1878+
createBranchRegion(S->getCond(), Counter::getZero(), DefaultCount);
18911879
}
18921880
}
18931881

Diff for: clang/test/CoverageMapping/branch-constfolded.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -5,94 +5,94 @@
55

66
// CHECK-LABEL: _Z6fand_0b:
77
bool fand_0(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:20 = M:3, C:2
8-
return false && a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, 0
8+
return false && a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, (#0 - #1)
99
} // CHECK: Branch,File 0, [[@LINE-1]]:19 -> [[@LINE-1]]:20 = #2, (#1 - #2)
1010

1111
// CHECK-LABEL: _Z6fand_1b:
1212
bool fand_1(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:19 = M:3, C:2
1313
return a && true; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = #1, (#0 - #1)
14-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = 0, 0
14+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = #2, 0
1515

1616
// CHECK-LABEL: _Z6fand_2bb:
1717
bool fand_2(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:25 = M:4, C:3
18-
return false && a && b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, 0
18+
return false && a && b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, (#0 - #3)
1919
} // CHECK: Branch,File 0, [[@LINE-1]]:19 -> [[@LINE-1]]:20 = #4, (#3 - #4)
2020
// CHECK: Branch,File 0, [[@LINE-2]]:24 -> [[@LINE-2]]:25 = #2, (#1 - #2)
2121

2222
// CHECK-LABEL: _Z6fand_3bb:
2323
bool fand_3(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:24 = M:4, C:3
2424
return a && true && b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = #3, (#0 - #3)
25-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = 0, 0
25+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = #4, 0
2626
// CHECK: Branch,File 0, [[@LINE-2]]:23 -> [[@LINE-2]]:24 = #2, (#1 - #2)
2727

2828
// CHECK-LABEL: _Z6fand_4bb:
2929
bool fand_4(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:25 = M:4, C:3
3030
return a && b && false; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = #3, (#0 - #3)
3131
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:16 = #4, (#3 - #4)
32-
// CHECK: Branch,File 0, [[@LINE-2]]:20 -> [[@LINE-2]]:25 = 0, 0
32+
// CHECK: Branch,File 0, [[@LINE-2]]:20 -> [[@LINE-2]]:25 = 0, (#1 - #2)
3333

3434
// CHECK-LABEL: _Z6fand_5b:
3535
bool fand_5(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:23 = M:3, C:2
36-
return false && true; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, 0
37-
} // CHECK: Branch,File 0, [[@LINE-1]]:19 -> [[@LINE-1]]:23 = 0, 0
36+
return false && true; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, (#0 - #1)
37+
} // CHECK: Branch,File 0, [[@LINE-1]]:19 -> [[@LINE-1]]:23 = #2, 0
3838

3939
// CHECK-LABEL: _Z6fand_6b:
4040
bool fand_6(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:19 = M:3, C:2
41-
return true && a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = 0, 0
41+
return true && a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = #1, 0
4242
} // CHECK: Branch,File 0, [[@LINE-1]]:18 -> [[@LINE-1]]:19 = #2, (#1 - #2)
4343

4444
// CHECK-LABEL: _Z6fand_7b:
4545
bool fand_7(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:20 = M:3, C:2
4646
return a && false; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = #1, (#0 - #1)
47-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, 0
47+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, (#1 - #2)
4848

4949
// CHECK-LABEL: _Z5for_0b:
5050
bool for_0(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:19 = M:3, C:2
51-
return true || a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = 0, 0
51+
return true || a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = (#0 - #1), 0
5252
} // CHECK: Branch,File 0, [[@LINE-1]]:18 -> [[@LINE-1]]:19 = (#1 - #2), #2
5353

5454
// CHECK-LABEL: _Z5for_1b:
5555
bool for_1(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:20 = M:3, C:2
5656
return a || false; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = (#0 - #1), #1
57-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, 0
57+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, #2
5858

5959
// CHECK-LABEL: _Z5for_2bb:
6060
bool for_2(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:24 = M:4, C:3
61-
return true || a || b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = 0, 0
61+
return true || a || b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = (#0 - #3), 0
6262
} // CHECK: Branch,File 0, [[@LINE-1]]:18 -> [[@LINE-1]]:19 = (#3 - #4), #4
6363
// CHECK: Branch,File 0, [[@LINE-2]]:23 -> [[@LINE-2]]:24 = (#1 - #2), #2
6464

6565
// CHECK-LABEL: _Z5for_3bb:
6666
bool for_3(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:25 = M:4, C:3
6767
return a || false || b; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = (#0 - #3), #3
68-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, 0
68+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:20 = 0, #4
6969
// CHECK: Branch,File 0, [[@LINE-2]]:24 -> [[@LINE-2]]:25 = (#1 - #2), #2
7070

7171
// CHECK-LABEL: _Z5for_4bb:
7272
bool for_4(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:24 = M:4, C:3
7373
return a || b || true; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = (#0 - #3), #3
7474
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:16 = (#3 - #4), #4
75-
// CHECK: Branch,File 0, [[@LINE-2]]:20 -> [[@LINE-2]]:24 = 0, 0
75+
// CHECK: Branch,File 0, [[@LINE-2]]:20 -> [[@LINE-2]]:24 = (#1 - #2), 0
7676

7777
// CHECK-LABEL: _Z5for_5b:
7878
bool for_5(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:23 = M:3, C:2
79-
return true || false; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = 0, 0
80-
} // CHECK: Branch,File 0, [[@LINE-1]]:18 -> [[@LINE-1]]:23 = 0, 0
79+
return true || false; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:14 = (#0 - #1), 0
80+
} // CHECK: Branch,File 0, [[@LINE-1]]:18 -> [[@LINE-1]]:23 = 0, #2
8181

8282
// CHECK-LABEL: _Z5for_6b:
8383
bool for_6(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:20 = M:3, C:2
84-
return false || a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, 0
84+
return false || a; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:15 = 0, #1
8585
} // CHECK: Branch,File 0, [[@LINE-1]]:19 -> [[@LINE-1]]:20 = (#1 - #2), #2
8686

8787
// CHECK-LABEL: _Z5for_7b:
8888
bool for_7(bool a) { // MCDC: Decision,File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:19 = M:3, C:2
8989
return a || true; // CHECK: Branch,File 0, [[@LINE]]:10 -> [[@LINE]]:11 = (#0 - #1), #1
90-
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = 0, 0
90+
} // CHECK: Branch,File 0, [[@LINE-1]]:15 -> [[@LINE-1]]:19 = (#1 - #2), 0
9191

9292
// CHECK-LABEL: _Z5for_8b:
9393
bool for_8(bool a) { // MCDC: Decision,File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:20 = M:3, C:2
94-
// CHECK: Branch,File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:11 = 0, 0
95-
// CHECK: Branch,File 0, [[@LINE+1]]:15 -> [[@LINE+1]]:20 = 0, 0
94+
// CHECK: Branch,File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:11 = #2, 0
95+
// CHECK: Branch,File 0, [[@LINE+1]]:15 -> [[@LINE+1]]:20 = 0, (#2 - #3)
9696
if (true && false)
9797
return true;
9898
else

Diff for: clang/test/CoverageMapping/if.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct S {
1414
// CHECK-LABEL: _Z3foov:
1515
// CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
1616
// CHECK-NEXT: [[@LINE+3]]:15 -> [[@LINE+3]]:19 = #0
17-
// CHECK-NEXT: Branch,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = 0, 0
17+
// CHECK-NEXT: Branch,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = #2, 0
1818
void foo() { // CHECK-NEXT: Gap,File 0, [[@LINE+1]]:21 -> [[@LINE+1]]:22 = #2
1919
if (int j = true ? nop() // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = #2
2020
: nop(); // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = (#0 - #2)
@@ -168,7 +168,7 @@ int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 =
168168
// GH-45481
169169
S s;
170170
s.the_prop = 0? 1 : 2; // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE]]:17 = #0
171-
// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 -> [[@LINE-1]]:17 = 0, 0
171+
// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 -> [[@LINE-1]]:17 = 0, (#0 - #7)
172172
// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> [[@LINE-2]]:19 = #7
173173
// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> [[@LINE-3]]:20 = #7
174174
// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> [[@LINE-4]]:24 = (#0 - #7)

Diff for: clang/test/CoverageMapping/macro-expansion.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
// CHECK: File 1, [[@LINE+7]]:12 -> [[@LINE+7]]:38 = #0
55
// CHECK-NEXT: File 1, [[@LINE+6]]:15 -> [[@LINE+6]]:28 = (#0 + #2)
66
// CHECK-NEXT: File 1, [[@LINE+5]]:21 -> [[@LINE+5]]:22 = (#0 + #2)
7-
// CHECK: Branch,File 1, [[@LINE+4]]:21 -> [[@LINE+4]]:22 = 0, 0
7+
// CHECK: Branch,File 1, [[@LINE+4]]:21 -> [[@LINE+4]]:22 = 0, ((#0 + #2) - #3)
88
// CHECK-NEXT: File 1, [[@LINE+3]]:24 -> [[@LINE+3]]:26 = #3
99
// CHECK-NEXT: File 1, [[@LINE+2]]:36 -> [[@LINE+2]]:37 = (#0 + #2)
10-
// CHECK-NEXT: Branch,File 1, [[@LINE+1]]:36 -> [[@LINE+1]]:37 = 0, 0
10+
// CHECK-NEXT: Branch,File 1, [[@LINE+1]]:36 -> [[@LINE+1]]:37 = 0, #0
1111
#define M1 do { if (0) {} } while (0)
1212
// CHECK-NEXT: File 2, [[@LINE+12]]:15 -> [[@LINE+12]]:41 = #0
1313
// CHECK-NEXT: File 2, [[@LINE+11]]:18 -> [[@LINE+11]]:31 = (#0 + #4)
1414
// CHECK-NEXT: File 2, [[@LINE+10]]:24 -> [[@LINE+10]]:25 = (#0 + #4)
1515
// CHECK: File 2, [[@LINE+9]]:27 -> [[@LINE+9]]:29 = #5
1616
// CHECK-NEXT: File 2, [[@LINE+8]]:39 -> [[@LINE+8]]:40 = (#0 + #4)
17-
// CHECK-NEXT: Branch,File 2, [[@LINE+7]]:39 -> [[@LINE+7]]:40 = 0, 0
17+
// CHECK-NEXT: Branch,File 2, [[@LINE+7]]:39 -> [[@LINE+7]]:40 = 0, #0
1818
// CHECK-NEXT: File 3, [[@LINE+6]]:15 -> [[@LINE+6]]:41 = #0
1919
// CHECK-NEXT: File 3, [[@LINE+5]]:18 -> [[@LINE+5]]:31 = (#0 + #6)
2020
// CHECK-NEXT: File 3, [[@LINE+4]]:24 -> [[@LINE+4]]:25 = (#0 + #6)
2121
// CHECK: File 3, [[@LINE+3]]:27 -> [[@LINE+3]]:29 = #7
2222
// CHECK-NEXT: File 3, [[@LINE+2]]:39 -> [[@LINE+2]]:40 = (#0 + #6)
23-
// CHECK-NEXT: Branch,File 3, [[@LINE+1]]:39 -> [[@LINE+1]]:40 = 0, 0
23+
// CHECK-NEXT: Branch,File 3, [[@LINE+1]]:39 -> [[@LINE+1]]:40 = 0, #0
2424
#define M2(x) do { if (x) {} } while (0)
2525
// CHECK-NEXT: File 4, [[@LINE+5]]:15 -> [[@LINE+5]]:38 = #0
2626
// CHECK-NEXT: File 4, [[@LINE+4]]:18 -> [[@LINE+4]]:28 = (#0 + #8)
2727
// CHECK-NEXT: Expansion,File 4, [[@LINE+3]]:20 -> [[@LINE+3]]:22 = (#0 + #8)
2828
// CHECK-NEXT: File 4, [[@LINE+2]]:36 -> [[@LINE+2]]:37 = (#0 + #8)
29-
// CHECK-NEXT: Branch,File 4, [[@LINE+1]]:36 -> [[@LINE+1]]:37 = 0, 0
29+
// CHECK-NEXT: Branch,File 4, [[@LINE+1]]:36 -> [[@LINE+1]]:37 = 0, #0
3030
#define M3(x) do { M2(x); } while (0)
3131
// CHECK-NEXT: File 5, [[@LINE+4]]:15 -> [[@LINE+4]]:27 = #0
3232
// CHECK-NEXT: File 5, [[@LINE+3]]:16 -> [[@LINE+3]]:19 = #0

Diff for: clang/test/CoverageMapping/mcdc-scratch-space.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
// CHECK: builtin_macro0:
44
int builtin_macro0(int a) {
55
// CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:15 = M:3, C:2
6-
return (__LINE__ // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:11 = 0, 0 [1,2,0]
6+
return (__LINE__ // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:11 = #1, 0 [1,2,0]
77
&& a); // CHECK: Branch,File 0, [[@LINE]]:14 -> [[@LINE]]:15 = #2, (#1 - #2) [2,0,0]
88
}
99

1010
// CHECK: builtin_macro1:
1111
int builtin_macro1(int a) {
1212
// CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:22 = M:3, C:2
1313
return (a // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:12 = (#0 - #1), #1 [1,0,2]
14-
|| __LINE__); // CHECK: Branch,File 0, [[@LINE]]:14 -> [[@LINE]]:14 = 0, 0 [2,0,0]
14+
|| __LINE__); // CHECK: Branch,File 0, [[@LINE]]:14 -> [[@LINE]]:14 = (#1 - #2), 0 [2,0,0]
1515
}
1616

1717
#define PRE(x) pre_##x

Diff for: clang/test/CoverageMapping/mcdc-system-headers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
int func0(int a) {
1818
// CHECK: Decision,File 0, [[@LINE+3]]:11 -> [[@LINE+3]]:21 = M:3, C:2
1919
// W_SYS: Expansion,File 0, [[@LINE+2]]:11 -> [[@LINE+2]]:16 = #0 (Expanded file = 1)
20-
// X_SYS: Branch,File 0, [[@LINE+1]]:11 -> [[@LINE+1]]:11 = 0, 0 [1,2,0]
20+
// X_SYS: Branch,File 0, [[@LINE+1]]:11 -> [[@LINE+1]]:11 = #1, 0 [1,2,0]
2121
return (CONST && a);
2222
// CHECK: Branch,File 0, [[@LINE-1]]:20 -> [[@LINE-1]]:21 = #2, (#1 - #2) [2,0,0]
23-
// W_SYS: Branch,File 1, [[@LINE-16]]:15 -> [[@LINE-16]]:17 = 0, 0 [1,2,0]
23+
// W_SYS: Branch,File 1, [[@LINE-16]]:15 -> [[@LINE-16]]:17 = #1, 0 [1,2,0]
2424
}
2525

2626
// CHECK: _Z5func1ii:

0 commit comments

Comments
 (0)