[clang] [clang][CoverageMapping] do not emit gap when either end is an `ImplicitValueInitExpr` (PR #89564)
Wentao Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 21 20:02:12 PDT 2024
https://github.com/whentojump updated https://github.com/llvm/llvm-project/pull/89564
>From abbdb318d62bb2e5ab6f07e7d0fe11f4a06b5a11 Mon Sep 17 00:00:00 2001
From: Wentao Zhang <zhangwt1997 at gmail.com>
Date: Sun, 21 Apr 2024 21:27:01 -0500
Subject: [PATCH] [clang][CoverageMapping] do not emit gap when either end is
an ImplicitValueInitExpr
---
clang/lib/CodeGen/CoverageMappingGen.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 64c39c5de351c7..dd8c0577d758ca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1368,9 +1368,12 @@ struct CounterCoverageMappingBuilder
for (const Stmt *Child : S->children())
if (Child) {
// If last statement contains terminate statements, add a gap area
- // between the two statements. Skipping attributed statements, because
- // they don't have valid start location.
- if (LastStmt && HasTerminateStmt && !isa<AttributedStmt>(Child)) {
+ // between the two statements. Skipping attributed statements and
+ // implicit initializations, because they don't have valid source
+ // location.
+ if (LastStmt && HasTerminateStmt && !isa<AttributedStmt>(Child) &&
+ !isa<ImplicitValueInitExpr>(Child) &&
+ !isa<ImplicitValueInitExpr>(LastStmt)) {
auto Gap = findGapAreaBetween(getEnd(LastStmt), getStart(Child));
if (Gap)
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(),
More information about the cfe-commits
mailing list