summaryrefslogtreecommitdiffstats
path: root/test/CoverageMapping/includehell.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-02-18 21:24:51 +0000
committerJustin Bogner <mail@justinbogner.com>2015-02-18 21:24:51 +0000
commitad5a787c1d24443f5358966afb5025469d8ea4a3 (patch)
treea2d5a4494af779f20a0b96548e43bbea3565b547 /test/CoverageMapping/includehell.cpp
parent1bc0d0a5c9e9742ee09645361a8525e5947062bc (diff)
InstrProf: Rewrite most of coverage mapping generation in a simpler way
The coverage mapping generation code previously generated a large number of redundant coverage regions and then tried to merge similar ones back together. This then relied on some awkward heuristics to prevent combining of regions that were importantly different but happened to have the same count. The end result was inefficient and hard to follow. Now, we more carefully create the regions we actually want. This makes it much easier to create regions at precise locations as well as making the basic approach quite a bit easier to follow. There's still a fair bit of complexity here dealing with included code and macro expansions, but that's pretty hard to avoid without significantly reducing the quality of data we provide. I had to modify quite a few tests where the source ranges became more precise or the old ranges seemed to be wrong anyways, and I've added quite a few new tests since a large number of constructs didn't seem to be tested before. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CoverageMapping/includehell.cpp')
-rw-r--r--test/CoverageMapping/includehell.cpp76
1 files changed, 68 insertions, 8 deletions
diff --git a/test/CoverageMapping/includehell.cpp b/test/CoverageMapping/includehell.cpp
index dcc2eee58d..830bc4f450 100644
--- a/test/CoverageMapping/includehell.cpp
+++ b/test/CoverageMapping/includehell.cpp
@@ -1,12 +1,72 @@
-// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
-int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0
+int main() {
int x = 0;
- #include "Inputs/code.h" // CHECK-NEXT: Expansion,File 0, [[@LINE]]:12 -> [[@LINE]]:27 = #0 (Expanded file = 1)
+
+ #include "Inputs/starts_a_scope"
+ x = x;
+ #include "Inputs/code.h"
+ x = x;
+ #include "Inputs/ends_a_scope"
+
+ #include "Inputs/starts_a_scope"
+ #include "Inputs/code.h"
+ #include "Inputs/ends_a_scope"
+
+ #include "Inputs/starts_a_scope"
+ #include "Inputs/ends_a_scope"
+
return 0;
}
-// CHECK-NEXT: File 1, 1:1 -> 9:7 = #0
-// CHECK-NEXT: File 1, 2:13 -> 4:2 = #1
-// CHECK-NEXT: File 1, 4:8 -> 6:2 = (#0 - #1)
-// CHECK-NEXT: File 1, 7:11 -> 9:2 = #2
-// CHECK-NEXT: File 1, 9:8 -> 11:2 = (#0 - #2)
+
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-MAIN
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-START
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CODE
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-END
+
+// CHECK-MAIN: File [[MAIN:[0-9]]], 3:12 -> 20:2 = #0
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 6:12 -> 6:35 = #0
+// CHECK-MAIN-NEXT: File [[MAIN]], 6:35 -> 10:33 = #1
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 8:14 -> 8:29 = #1
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 10:12 -> 10:33 = #1
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 12:12 -> 12:35 = #0
+// CHECK-MAIN-NEXT: File [[MAIN]], 12:35 -> 14:33 = #5
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 13:14 -> 13:29 = #5
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 14:12 -> 14:33 = #5
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 16:12 -> 16:35 = #0
+// CHECK-MAIN-NEXT: File [[MAIN]], 16:35 -> 17:33 = #9
+// CHECK-MAIN-NEXT: Expansion,File [[MAIN]], 17:12 -> 17:33 = #9
+
+// CHECK-START: File [[START1:[0-9]]], 1:1 -> 5:1 = #0
+// CHECK-START-NEXT: File [[START1]], 4:17 -> 4:22 = (#0 + #1)
+// CHECK-START-NEXT: File [[START1]], 4:24 -> 4:27 = #1
+// CHECK-START-NEXT: File [[START1]], 4:29 -> 5:1 = #1
+// CHECK-START: File [[START2:[0-9]]], 1:1 -> 5:1 = #0
+// CHECK-START-NEXT: File [[START2]], 4:17 -> 4:22 = (#0 + #5)
+// CHECK-START-NEXT: File [[START2]], 4:24 -> 4:27 = #5
+// CHECK-START-NEXT: File [[START2]], 4:29 -> 5:1 = #5
+// CHECK-START: File [[START3:[0-9]]], 1:1 -> 5:1 = #0
+// CHECK-START-NEXT: File [[START3]], 4:17 -> 4:22 = (#0 + #9)
+// CHECK-START-NEXT: File [[START3]], 4:24 -> 4:27 = #9
+// CHECK-START-NEXT: File [[START3]], 4:29 -> 5:1 = #9
+
+// CHECK-CODE: File [[CODE1:[0-9]]], 1:1 -> 14:1 = #1
+// CHECK-CODE-NEXT: File [[CODE1]], 4:13 -> 6:2 = #2
+// CHECK-CODE-NEXT: File [[CODE1]], 6:8 -> 8:2 = (#1 - #2)
+// CHECK-CODE-NEXT: File [[CODE1]], 9:11 -> 11:2 = #3
+// CHECK-CODE-NEXT: File [[CODE1]], 11:8 -> 13:2 = (#1 - #3)
+// CHECK-CODE: File [[CODE2:[0-9]]], 1:1 -> 14:1 = #5
+// CHECK-CODE-NEXT: File [[CODE2]], 4:13 -> 6:2 = #6
+// CHECK-CODE-NEXT: File [[CODE2]], 6:8 -> 8:2 = (#5 - #6)
+// CHECK-CODE-NEXT: File [[CODE2]], 9:11 -> 11:2 = #7
+// CHECK-CODE-NEXT: File [[CODE2]], 11:8 -> 13:2 = (#5 - #7)
+
+// CHECK-END: File [[END1:[0-9]]], 1:1 -> 3:2 = #1
+// CHECK-END-NEXT: File [[END1]], 1:1 -> 6:1 = #0
+// CHECK-END-NEXT: File [[END1]], 5:11 -> 5:16 = #4
+// CHECK-END: File [[END2:[0-9]]], 1:1 -> 3:2 = #5
+// CHECK-END-NEXT: File [[END2]], 1:1 -> 6:1 = #0
+// CHECK-END-NEXT: File [[END2]], 5:11 -> 5:16 = #8
+// CHECK-END: File [[END3:[0-9]]], 1:1 -> 3:2 = #9
+// CHECK-END-NEXT: File [[END3]], 1:1 -> 6:1 = #0
+// CHECK-END-NEXT: File [[END3]], 5:11 -> 5:16 = #10