Skip to content

Commit

Permalink
[Coverage][NFC] Avoid visiting non-unique OpaqueValueExpr (llvm#88910)
Browse files Browse the repository at this point in the history
Only unique `OpaqueValueExpr`s should be handled in the mapping builder,
as
[discussed](llvm#85837 (comment))
in llvm#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`.
  • Loading branch information
bolshakov-a authored Apr 19, 2024
1 parent 89f8ba2 commit 949e66b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions clang/lib/CodeGen/CoverageMappingGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,11 +2011,13 @@ struct CounterCoverageMappingBuilder
Counter TrueCount = llvm::EnableSingleByteCoverage
? getRegionCounter(E->getTrueExpr())
: getRegionCounter(E);

propagateCounts(ParentCount, E->getCond());
Counter OutCount;

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

extendRegion(E->getTrueExpr());
OutCount = propagateCounts(TrueCount, E->getTrueExpr());
} else {
OutCount = TrueCount;
}

extendRegion(E->getFalseExpr());
Expand Down

0 comments on commit 949e66b

Please sign in to comment.