summaryrefslogtreecommitdiffstats
path: root/clang/test/CoverageMapping/macros.c
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/macros.c
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/macros.c')
-rw-r--r--clang/test/CoverageMapping/macros.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/clang/test/CoverageMapping/macros.c b/clang/test/CoverageMapping/macros.c
new file mode 100644
index 00000000000..f83b3f54898
--- /dev/null
+++ b/clang/test/CoverageMapping/macros.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
+
+void bar();
+#define MACRO return; bar()
+#define MACRO_2 bar()
+#define MACRO_1 return; MACRO_2
+
+void func() {
+ int i = 0;
+ MACRO;
+ i = 2;
+}
+
+// CHECK: func
+// CHECK-NEXT: File 0, 8:13 -> 12:2 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 0, 10:3 -> 10:8 = #0 (HasCodeBefore = 0, Expanded file = 1)
+// CHECK-NEXT: File 0, 11:3 -> 11:8 = 0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 4:15 -> 4:21 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 4:23 -> 4:28 = 0 (HasCodeBefore = 0)
+
+void func2() {
+ int i = 0;
+ MACRO_1;
+ i = 2;
+}
+
+// CHECK-NEXT: func2
+// CHECK-NEXT: File 0, 21:14 -> 25:2 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 0, 23:3 -> 23:10 = #0 (HasCodeBefore = 0, Expanded file = 1)
+// CHECK-NEXT: File 0, 24:3 -> 24:8 = 0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 6:17 -> 6:23 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 1, 6:25 -> 6:32 = 0 (HasCodeBefore = 0, Expanded file = 2)
+// CHECK-NEXT: File 2, 5:17 -> 5:22 = 0 (HasCodeBefore = 0)
+
+int main() {
+ func();
+ func2();
+ return 0;
+}
+
+void bar() {
+}
OpenPOWER on IntegriCloud