This is an archive of the discontinued LLVM Phabricator instance.

[LLVM-COV] Fix an issue: a statement after calling 'assert()' function is wrongly marked as 'not executed'
ClosedPublic

Authored by MaggieYi on Feb 20 2023, 2:32 AM.

Details

Summary

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.

The following issues are fixed by this patch:

  1. https://github.com/llvm/llvm-project/issues/59030
  2. https://github.com/llvm/llvm-project/issues/57388
  3. https://github.com/llvm/llvm-project/issues/57481
  4. https://github.com/llvm/llvm-project/issues/60701

Diff Detail

Event Timeline

MaggieYi created this revision.Feb 20 2023, 2:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2023, 2:32 AM
MaggieYi requested review of this revision.Feb 20 2023, 2:32 AM

Gentle ping ...

Thanks for fixing it.

Just one comment.

clang/test/CoverageMapping/terminate-statements.cpp
335

For completeness, can you add following two tests:

( true ? abort() : void (0) );
( false ? abort() : void (0) );
MaggieYi updated this revision to Diff 501509.Mar 1 2023, 7:36 AM

Thanks Zequan. I have added two tests following your suggestion.

Kind regards,
Maggie

MaggieYi marked an inline comment as done.Mar 1 2023, 7:38 AM
MaggieYi added inline comments.
clang/test/CoverageMapping/terminate-statements.cpp
335

Thanks, two tests have been added.

zequanwu accepted this revision.Mar 1 2023, 7:55 AM

LGTM.

This revision is now accepted and ready to land.Mar 1 2023, 7:55 AM
This revision was automatically updated to reflect the committed changes.
MaggieYi marked an inline comment as done.