aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorDavid Tellenbach <dtellenbach@apple.com>2024-02-18 14:34:35 -0800
committerGitHub <noreply@github.com>2024-02-18 14:34:35 -0800
commitdc94eb57e39a925a9672bfc4d7cba0fb0da874d8 (patch)
treedc09f251ac2ee3d60710b2f1c86529820151e458 /clang/lib/CodeGen/CoverageMappingGen.cpp
parent5e83b26584c9a02f8a2923651d08cad2dcc8479a (diff)
downloadllvm-dc94eb57e39a925a9672bfc4d7cba0fb0da874d8.zip
llvm-dc94eb57e39a925a9672bfc4d7cba0fb0da874d8.tar.gz
llvm-dc94eb57e39a925a9672bfc4d7cba0fb0da874d8.tar.bz2
[clang][CodeCoverage] Fix CoverageMapping for binary conditionals ops (#82141)
Fix an issue that produces a wrong coverage mapping when using binary conditional operators as show in the example below. Before this patch: 1| 1|int binary_cond(int x) { 2| 1| x = x ?: 4; 3| 1| int y = 0; 4| 0| return x; <-- Not covered 5| 1|} After this patch: 1| 1|int binary_cond(int x) { 2| 1| x = x ?: 4; 3| 1| int y = 0; 4| 1| return x; <-- Covered 5| 1|}
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index c10d85e..d8fa69d 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1942,6 +1942,8 @@ struct CounterCoverageMappingBuilder
extendRegion(E->getTrueExpr());
OutCount = propagateCounts(TrueCount, E->getTrueExpr());
+ } else {
+ OutCount = TrueCount;
}
extendRegion(E->getFalseExpr());