]> granicus.if.org Git - clang/commit
[Coverage] Precise region termination with deferred regions
authorVedant Kumar <vsk@apple.com>
Fri, 4 Aug 2017 00:29:20 +0000 (00:29 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 4 Aug 2017 00:29:20 +0000 (00:29 +0000)
commitaa72e29f10cd56844d408a5fc4b403190684a663
tree2f75d6cafd04f03623120b89808d6f4f413b66c1
parent469977f45cc099675015ebeafa4b98b969f8b70b
[Coverage] Precise region termination with deferred regions

The current coverage implementation doesn't handle region termination
very precisely. Take for example an `if' statement with a `return':

  void f() {
    if (true) {
      return; // The `if' body's region is terminated here.
    }
    // This line gets the same coverage as the `if' condition.
  }

If the function `f' is called, the line containing the comment will be
marked as having executed once, which is not correct.

The solution here is to create a deferred region after terminating a
region. The deferred region is completed once the start location of the
next statement is known, and is then pushed onto the region stack.
In the cases where it's not possible to complete a deferred region, it
can safely be dropped.

Testing: lit test updates, a stage2 coverage-enabled build of clang

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310010 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/deferred-region.cpp [new file with mode: 0644]
test/CoverageMapping/label.cpp
test/CoverageMapping/moremacros.c
test/CoverageMapping/return.c
test/CoverageMapping/switch.cpp
test/CoverageMapping/switchmacro.c
test/CoverageMapping/trycatch.cpp