@@ -944,9 +944,18 @@ struct CounterCoverageMappingBuilder
944
944
return {ExecCnt, Builder.subtract (ParentCnt, ExecCnt)};
945
945
}
946
946
947
- Counter getSwitchImplicitDefaultCounter (const Stmt *Cond, Counter ParentCount,
948
- Counter CaseCountSum) {
949
- return Builder.subtract (ParentCount, CaseCountSum);
947
+ // / Returns {TrueCnt,FalseCnt} for "implicit default".
948
+ // / FalseCnt is considered as the False count on SwitchStmt.
949
+ std::pair<Counter, Counter>
950
+ getSwitchImplicitDefaultCounterPair (const Stmt *Cond, Counter ParentCount,
951
+ Counter CaseCountSum) {
952
+ // Simplify is skipped while building the counters above: it can get
953
+ // really slow on top of switches with thousands of cases. Instead,
954
+ // trigger simplification by adding zero to the last counter.
955
+ CaseCountSum =
956
+ addCounters (CaseCountSum, Counter::getZero (), /* Simplify=*/ true );
957
+
958
+ return {CaseCountSum, Builder.subtract (ParentCount, CaseCountSum)};
950
959
}
951
960
952
961
bool IsCounterEqual (Counter OutCount, Counter ParentCount) {
@@ -1907,15 +1916,9 @@ struct CounterCoverageMappingBuilder
1907
1916
// the hidden branch, which will be added later by the CodeGen. This region
1908
1917
// will be associated with the switch statement's condition.
1909
1918
if (!HasDefaultCase) {
1910
- // Simplify is skipped while building the counters above: it can get
1911
- // really slow on top of switches with thousands of cases. Instead,
1912
- // trigger simplification by adding zero to the last counter.
1913
- CaseCountSum =
1914
- addCounters (CaseCountSum, Counter::getZero (), /* Simplify=*/ true );
1915
-
1916
- // This is considered as the False count on SwitchStmt.
1917
- Counter SwitchFalse = subtractCounters (ParentCount, CaseCountSum);
1918
- createBranchRegion (S->getCond (), CaseCountSum, SwitchFalse);
1919
+ auto Counters = getSwitchImplicitDefaultCounterPair (
1920
+ S->getCond (), ParentCount, CaseCountSum);
1921
+ createBranchRegion (S->getCond (), Counters.first , Counters.second );
1919
1922
}
1920
1923
}
1921
1924
0 commit comments