From dc94eb57e39a925a9672bfc4d7cba0fb0da874d8 Mon Sep 17 00:00:00 2001 From: David Tellenbach Date: Sun, 18 Feb 2024 14:34:35 -0800 Subject: [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|} --- clang/lib/CodeGen/CoverageMappingGen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp') 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()); -- cgit v1.1