forked from OSchip/llvm-project
[Coverage] Propogate counter to condition of conditional operator
Clang usually propagates counter mapping region for conditions of `if`, `while`, `for`, etc from parent counter. We should do the same for condition of conditional operator. Differential Revision: https://reviews.llvm.org/D95918
This commit is contained in:
parent
d41c6d51cb
commit
4dc08cc3aa
|
@ -1462,7 +1462,7 @@ struct CounterCoverageMappingBuilder
|
|||
Counter ParentCount = getRegion().getCounter();
|
||||
Counter TrueCount = getRegionCounter(E);
|
||||
|
||||
Visit(E->getCond());
|
||||
propagateCounts(ParentCount, E->getCond());
|
||||
|
||||
if (!isa<BinaryConditionalOperator>(E)) {
|
||||
// The 'then' count applies to the area immediately after the condition.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
int nop() { return 0; }
|
||||
|
||||
// CHECK-LABEL: _Z3foov:
|
||||
// CHECK-NEXT: [[@LINE+2]]:12 -> [[@LINE+7]]:2 = #0
|
||||
// CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
|
||||
// CHECK-NEXT: [[@LINE+3]]:15 -> [[@LINE+3]]:19 = #0
|
||||
// CHECK-NEXT: Branch,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = 0, 0
|
||||
void foo() { // CHECK-NEXT: Gap,File 0, [[@LINE+1]]:20 -> [[@LINE+1]]:22 = #2
|
||||
if (int j = true ? nop() // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = #2
|
||||
|
@ -38,11 +39,13 @@ int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 =
|
|||
i = 3; // CHECK-NEXT: File 0, [[@LINE-1]]:10 -> [[@LINE+1]]:4 = (#0 - #4)
|
||||
}
|
||||
|
||||
// CHECK-NEXT: File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:13 = #0
|
||||
// CHECK-NEXT: Branch,File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:13 = #5, (#0 - #5)
|
||||
i = i == 0? // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+1]]:9 = #5
|
||||
i + 1 : // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = #5
|
||||
i + 2; // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = (#0 - #5)
|
||||
|
||||
// CHECK-NEXT: File 0, [[@LINE+4]]:7 -> [[@LINE+4]]:13 = #0
|
||||
// CHECK-NEXT: Branch,File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:13 = #6, (#0 - #6)
|
||||
// CHECK-NEXT: Gap,File 0, [[@LINE+2]]:13 -> [[@LINE+2]]:14 = #6
|
||||
// CHECK-NEXT: File 0, [[@LINE+1]]:14 -> [[@LINE+1]]:20 = #6
|
||||
|
|
|
@ -83,20 +83,23 @@ void foo(int i) {
|
|||
// CHECK: File 0, [[@LINE+1]]:42 -> [[@LINE+1]]:44 = #7
|
||||
for (DECL(int, j) : ARR(int, 1, 2, 3)) {}
|
||||
|
||||
// CHECK-NEXT: File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #0
|
||||
// CHECK-NEXT: Branch,File 0, [[@LINE+3]]:10 -> [[@LINE+3]]:11 = #8, (#0 - #8)
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = #0
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:23 -> [[@LINE+1]]:29 = #0
|
||||
(void)(i ? PRIo64 : PRIu64);
|
||||
|
||||
// CHECK-NEXT: File 0, [[@LINE+6]]:10 -> [[@LINE+6]]:11 = #0
|
||||
// CHECK: File 0, [[@LINE+5]]:14 -> [[@LINE+5]]:15 = #9
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:18 -> [[@LINE+4]]:22 = (#0 - #9)
|
||||
// CHECK-NEXT: File 0, [[@LINE+3]]:22 -> [[@LINE+3]]:33 = (#0 - #9)
|
||||
// CHECK-NEXT: File 0, [[@LINE+4]]:18 -> [[@LINE+4]]:33 = (#0 - #9)
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:18 -> [[@LINE+3]]:22 = (#0 - #9)
|
||||
// CHECK: File 0, [[@LINE+2]]:28 -> [[@LINE+2]]:29 = #10
|
||||
// CHECK-NEXT: File 0, [[@LINE+1]]:32 -> [[@LINE+1]]:33 = ((#0 - #9) - #10)
|
||||
(void)(i ? i : EXPR(i) ? i : 0);
|
||||
// CHECK-NEXT: File 0, [[@LINE+5]]:10 -> [[@LINE+5]]:11 = #0
|
||||
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #11, (#0 - #11)
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:15 -> [[@LINE+3]]:19 = (#0 - #11)
|
||||
// CHECK-NEXT: File 0, [[@LINE+2]]:19 -> [[@LINE+2]]:27 = (#0 - #11)
|
||||
// CHECK-NEXT: File 0, [[@LINE+3]]:15 -> [[@LINE+3]]:27 = (#0 - #11)
|
||||
// CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = (#0 - #11)
|
||||
// CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:27 = ((#0 - #11) - #12)
|
||||
(void)(i ?: EXPR(i) ?: 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue