[Coverage] Fix an issue: a statement after calling 'assert()' function is wrongly
authorYing Yi <maggieyi666@gmail.com>
Fri, 17 Feb 2023 11:42:20 +0000 (11:42 +0000)
committerYing Yi <maggieyi666@gmail.com>
Thu, 2 Mar 2023 09:14:44 +0000 (09:14 +0000)
commit94dd4766a61bb18b263415e17e745dc2fa609162
tree6ed56c735e45b6a5fb33928e0491df6197d63712
parentd94e8479fcd7cd57fa9c6f3f3aa24d2ad3e11d89
[Coverage] Fix an issue: a statement after calling 'assert()' function is wrongly
marked as 'not executed'.

In the current coverage mapping implementation, we terminate the current region
and start a zero region when we hit a nonreturn function. However, for logical OR,
the second operand is not executed if the first operand evaluates to true. If the
nonreturn function is called in the right side of logical OR and the left side of
logical OR is TRUE, we should not start a zero `GapRegionCounter`. This will also
apply to `VisitAbstractConditionalOperator`.

Fixes https://github.com/llvm/llvm-project/issues/59030

Reviewed By: zequanwu

Differential Revision: https://reviews.llvm.org/D144371
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/terminate-statements.cpp