summaryrefslogtreecommitdiffstats
path: root/clang/test/CoverageMapping/loops.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2014-08-08 23:49:58 +0000
committerAlex Lorenz <arphaman@gmail.com>2014-08-08 23:49:58 +0000
commitc4ea74a719115b9b663ae23370567420c6626966 (patch)
treec5199e539d317265b04a4438fe0044f978641382 /clang/test/CoverageMapping/loops.cpp
parenta2acb1e84effd2794aa7515261806f286b86432f (diff)
downloadbcm5719-llvm-c4ea74a719115b9b663ae23370567420c6626966.tar.gz
bcm5719-llvm-c4ea74a719115b9b663ae23370567420c6626966.zip
Add tests for coverage mapping generation.
This patch adds the tests for the coverage mapping generation. Most of the tests check the mapping regions produced by the generator, and one checks the llvm IR. Differential Revision: http://reviews.llvm.org/D4793 llvm-svn: 215261
Diffstat (limited to 'clang/test/CoverageMapping/loops.cpp')
-rw-r--r--clang/test/CoverageMapping/loops.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/clang/test/CoverageMapping/loops.cpp b/clang/test/CoverageMapping/loops.cpp
new file mode 100644
index 00000000000..8d189c2384c
--- /dev/null
+++ b/clang/test/CoverageMapping/loops.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
+
+void rangedFor() {
+ int arr[] = { 1, 2, 3, 4, 5 };
+ int sum = 0;
+ for(auto i : arr) {
+ sum += i;
+ if(i == 3)
+ break;
+ }
+}
+
+// CHECK: rangedFor
+// CHECK-NEXT: File 0, 3:18 -> 11:2 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 6:21 -> 10:4 = #1 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 9:7 -> 9:12 = #2 (HasCodeBefore = 0)
+
+int main() {
+ for(int i = 0; i < 10; ++i)
+ ;
+ for(int i = 0; i < 0; ++i)
+ ;
+ for(int i = 0;
+ i < 10;
+ ++i)
+ {
+ int x = 0;
+ }
+ int j = 0;
+ while(j < 5) ++j;
+ do {
+ ++j;
+ } while(j < 10);
+ j = 0;
+ while
+ (j < 5)
+ ++j;
+ do
+ ++j;
+ while(j < 10);
+ rangedFor();
+ return 0;
+}
+
+// CHECK-NEXT: main
+// CHECK-NEXT: File 0, 18:12 -> 43:2 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 19:18 -> 19:24 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 19:26 -> 19:29 = #1 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 20:6 -> 20:7 = #1 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 21:18 -> 21:23 = (#0 + #2) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 21:25 -> 21:28 = #2 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 22:6 -> 22:7 = #2 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 24:7 -> 24:13 = (#0 + #3) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 25:7 -> 25:10 = #3 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 26:3 -> 28:4 = #3 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 30:9 -> 30:14 = (#0 + #4) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 30:16 -> 30:19 = #4 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 31:6 -> 33:17 = (#0 + #5) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 36:5 -> 36:10 = (#0 + #6) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 37:6 -> 37:9 = #6 (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 39:5 -> 40:15 = (#0 + #7) (HasCodeBefore = 0)
OpenPOWER on IntegriCloud