aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorAndrey Ali Khan Bolshakov <bolsh.andrey@yandex.ru>2024-04-19 03:04:26 +0300
committerGitHub <noreply@github.com>2024-04-18 17:04:26 -0700
commit949e66baf1c5d97dc60a243d9b66df5216255343 (patch)
treec6744c75637262b66531ec5bb8797ac7916fdf8b /clang/lib/CodeGen/CoverageMappingGen.cpp
parent89f8ba2855789c6c8b445af0e1aa82d5f5cf940a (diff)
downloadllvm-949e66baf1c5d97dc60a243d9b66df5216255343.zip
llvm-949e66baf1c5d97dc60a243d9b66df5216255343.tar.gz
llvm-949e66baf1c5d97dc60a243d9b66df5216255343.tar.bz2
[Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (#88910)
Only unique `OpaqueValueExpr`s should be handled in the mapping builder, as [discussed](https://github.com/llvm/llvm-project/pull/85837#discussion_r1542056451) 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`.
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 71215da..64c39c5 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -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()));
@@ -2024,8 +2026,6 @@ struct CounterCoverageMappingBuilder
extendRegion(E->getTrueExpr());
OutCount = propagateCounts(TrueCount, E->getTrueExpr());
- } else {
- OutCount = TrueCount;
}
extendRegion(E->getFalseExpr());