diff options
author | Igor Kudrin <ikudrin.dev@gmail.com> | 2016-08-29 11:48:50 +0000 |
---|---|---|
committer | Igor Kudrin <ikudrin.dev@gmail.com> | 2016-08-29 11:48:50 +0000 |
commit | dad737bdb64d7c20e1c5163c2d70f61b9d5a3427 (patch) | |
tree | 761392bab077e2c01cc4d82f84046d9ab45702b4 /test/CoverageMapping | |
parent | 47e160c4ac62f7354755fe6063896fba58e9a71d (diff) |
[Coverage] Prevent creating a redundant counter if a nested body ends with a macro.
If there were several nested statements arranged in a way that all of them
end up with the same macro, then the expansion of this macro was assigned
with all the corresponding counters of these statements.
As a result, the wrong counter value was shown for the macro in llvm-cov.
This patch fixes the issue by preventing adding a counter for an expanded
source range if it already has an assigned counter, which is expected
to come from the most specific statement.
Differential Revision: https://reviews.llvm.org/D23160
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CoverageMapping')
-rw-r--r-- | test/CoverageMapping/macros.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/CoverageMapping/macros.c b/test/CoverageMapping/macros.c index f633961439..8e2355b1ab 100644 --- a/test/CoverageMapping/macros.c +++ b/test/CoverageMapping/macros.c @@ -36,8 +36,20 @@ void func3() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+3]]:2 = #0 // CHECK-NEXT: File 1, 4:17 -> 4:22 = #0 // CHECK-NEXT: File 2, 4:17 -> 4:22 = #0 +// CHECK-NEXT: func4 +void func4() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+6]]:2 = #0 + int i = 0; + while (i++ < 10) // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:18 = (#0 + #1) + if (i < 5) // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:14 = #1 + // CHECK-NEXT: File 0, [[@LINE-1]]:9 -> [[@LINE-1]]:14 = #1 + MACRO_2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:7 -> [[@LINE]]:14 = #2 +} +// CHECK-NEXT: File 1, 4:17 -> 4:22 = #2 +// CHECK-NOT: File 1 + int main(int argc, const char *argv[]) { func(); func2(); func3(); + func4(); } |