[Coverage] Precise region termination with deferred regions (reapply)
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 This is a reapplication but there are no changes from the original commit. With D36813, the segment builder in llvm will be able to handle deferred regions correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312818 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- lib/CodeGen/CoverageMappingGen.cpp 86 additions, 5 deletionslib/CodeGen/CoverageMappingGen.cpp
- test/CoverageMapping/deferred-region.cpp 165 additions, 0 deletionstest/CoverageMapping/deferred-region.cpp
- test/CoverageMapping/label.cpp 16 additions, 9 deletionstest/CoverageMapping/label.cpp
- test/CoverageMapping/moremacros.c 3 additions, 3 deletionstest/CoverageMapping/moremacros.c
- test/CoverageMapping/return.c 1 addition, 1 deletiontest/CoverageMapping/return.c
- test/CoverageMapping/switch.cpp 3 additions, 3 deletionstest/CoverageMapping/switch.cpp
- test/CoverageMapping/switchmacro.c 1 addition, 0 deletionstest/CoverageMapping/switchmacro.c
- test/CoverageMapping/trycatch.cpp 1 addition, 1 deletiontest/CoverageMapping/trycatch.cpp
Loading
Please register or sign in to comment