Skip to content

Commit c7359dd

Browse files
committed
move into findGapAreaBetween
1 parent 6a00626 commit c7359dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,12 @@ struct CounterCoverageMappingBuilder
12081208
/// Find a valid gap range between \p AfterLoc and \p BeforeLoc.
12091209
std::optional<SourceRange> findGapAreaBetween(SourceLocation AfterLoc,
12101210
SourceLocation BeforeLoc) {
1211+
// Some statements (like AttributedStmt and ImplicitValueInitExpr) don't
1212+
// have valid source locations. Do not emit a gap region if this is the case
1213+
// in either AfterLoc end or BeforeLoc end.
1214+
if (AfterLoc.isInvalid() || BeforeLoc.isInvalid())
1215+
return std::nullopt;
1216+
12111217
// If AfterLoc is in function-like macro, use the right parenthesis
12121218
// location.
12131219
if (AfterLoc.isMacroID()) {
@@ -1368,9 +1374,8 @@ struct CounterCoverageMappingBuilder
13681374
for (const Stmt *Child : S->children())
13691375
if (Child) {
13701376
// If last statement contains terminate statements, add a gap area
1371-
// between the two statements. Skipping attributed statements, because
1372-
// they don't have valid start location.
1373-
if (LastStmt && HasTerminateStmt && !isa<AttributedStmt>(Child)) {
1377+
// between the two statements.
1378+
if (LastStmt && HasTerminateStmt) {
13741379
auto Gap = findGapAreaBetween(getEnd(LastStmt), getStart(Child));
13751380
if (Gap)
13761381
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(),

0 commit comments

Comments
 (0)