Skip to content

Commit 949e66b

Browse files
authored
[Coverage][NFC] Avoid visiting non-unique OpaqueValueExpr (#88910)
Only unique `OpaqueValueExpr`s should be handled in the mapping builder, as [discussed](#85837 (comment)) in #85837. However, `getCond()` returns non-unique `OpaqueValueExpr` for `BinaryConditionalOperator` (because it is also used as the "true" branch expression). Use `getCommon()` instead so as to bypass the `OpaqueValueExpr`.
1 parent 89f8ba2 commit 949e66b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang/lib/CodeGen/CoverageMappingGen.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2011,11 +2011,13 @@ struct CounterCoverageMappingBuilder
20112011
Counter TrueCount = llvm::EnableSingleByteCoverage
20122012
? getRegionCounter(E->getTrueExpr())
20132013
: getRegionCounter(E);
2014-
2015-
propagateCounts(ParentCount, E->getCond());
20162014
Counter OutCount;
20172015

2018-
if (!isa<BinaryConditionalOperator>(E)) {
2016+
if (const auto *BCO = dyn_cast<BinaryConditionalOperator>(E)) {
2017+
propagateCounts(ParentCount, BCO->getCommon());
2018+
OutCount = TrueCount;
2019+
} else {
2020+
propagateCounts(ParentCount, E->getCond());
20192021
// The 'then' count applies to the area immediately after the condition.
20202022
auto Gap =
20212023
findGapAreaBetween(E->getQuestionLoc(), getStart(E->getTrueExpr()));
@@ -2024,8 +2026,6 @@ struct CounterCoverageMappingBuilder
20242026

20252027
extendRegion(E->getTrueExpr());
20262028
OutCount = propagateCounts(TrueCount, E->getTrueExpr());
2027-
} else {
2028-
OutCount = TrueCount;
20292029
}
20302030

20312031
extendRegion(E->getFalseExpr());

0 commit comments

Comments
 (0)