summaryrefslogtreecommitdiffstats
path: root/clang/test/CoverageMapping/macro-expressions.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
commitbf42cfd75fcaf6a98e8781cb49c07c181f6b4330 (patch)
tree4d68cf5ec62c0fc00c58817adfaf157a3b83d7d0 /clang/test/CoverageMapping/macro-expressions.cpp
parentcd8fb60fce21b985b87c0e9b7aaefc43e94f316b (diff)
downloadbcm5719-llvm-bf42cfd75fcaf6a98e8781cb49c07c181f6b4330.tar.gz
bcm5719-llvm-bf42cfd75fcaf6a98e8781cb49c07c181f6b4330.zip
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. llvm-svn: 229748
Diffstat (limited to 'clang/test/CoverageMapping/macro-expressions.cpp')
-rw-r--r--clang/test/CoverageMapping/macro-expressions.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/clang/test/CoverageMapping/macro-expressions.cpp b/clang/test/CoverageMapping/macro-expressions.cpp
new file mode 100644
index 00000000000..b9782b0c127
--- /dev/null
+++ b/clang/test/CoverageMapping/macro-expressions.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp %s | FileCheck %s
+
+#define EXPR(x) (x)
+#define NEXPR(x) (!x)
+#define DECL(T, x) T x
+#define ASSIGN(x, y) x = y
+#define LT(x, y) x < y
+#define INC(x) ++x
+#define ARR(T, x, y, z) (T[3]){x, y, z}
+
+#define PRI_64_LENGTH_MODIFIER "ll"
+#define PRIo64 PRI_64_LENGTH_MODIFIER "o"
+#define PRIu64 PRI_64_LENGTH_MODIFIER "u"
+
+// CHECK: foo
+// CHECK-NEXT: File 0, [[@LINE+1]]:17 -> {{[0-9]+}}:2 = #0
+void foo(int i) {
+ // CHECK-NEXT: File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:12 = #1
+ if (0) {}
+
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:11 = #0
+ // CHECK-NEXT: File 0, [[@LINE+1]]:16 -> [[@LINE+1]]:18 = #2
+ if (EXPR(i)) {}
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:9 -> [[@LINE+2]]:14 = (#0 + #3)
+ // CHECK-NEXT: File 0, [[@LINE+1]]:20 -> [[@LINE+1]]:22 = #3
+ for (;NEXPR(i);) {}
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:8 -> [[@LINE+4]]:14 = #0
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:33 -> [[@LINE+3]]:35 = (#0 + #4)
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:43 -> [[@LINE+2]]:46 = #4
+ // CHECK-NEXT: File 0, [[@LINE+1]]:51 -> [[@LINE+1]]:53 = #4
+ for (ASSIGN(DECL(int, j), 0); LT(j, i); INC(j)) {}
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:9 = #0
+ ASSIGN(DECL(int, k), 0);
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:10 -> [[@LINE+3]]:12 = (#0 + #5)
+ // CHECK-NEXT: File 0, [[@LINE+2]]:20 -> [[@LINE+2]]:31 = #5
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:22 -> [[@LINE+1]]:25 = #5
+ while (LT(k, i)) { INC(k); }
+ // CHECK-NEXT: File 0, [[@LINE+2]]:6 -> [[@LINE+2]]:8 = (#0 + #6)
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:16 -> [[@LINE+1]]:21 = (#0 + #6)
+ do {} while (NEXPR(i));
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:8 -> [[@LINE+3]]:12 = #0
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:23 -> [[@LINE+2]]:26 = #0
+ // CHECK-NEXT: File 0, [[@LINE+1]]:42 -> [[@LINE+1]]:44 = #7
+ for (DECL(int, j) : ARR(int, 1, 2, 3)) {}
+
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = #8
+ // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:23 -> [[@LINE+1]]:29 = #0
+ (void)(i ? PRIo64 : PRIu64);
+}
+
+// CHECK-NEXT: File {{[0-9]+}}, 3:17 -> 3:20 = #0
+// CHECK-NEXT: File {{[0-9]+}}, 4:18 -> 4:22 = (#0 + #3)
+// CHECK-NEXT: File {{[0-9]+}}, 6:22 -> 6:27 = #0
+// CHECK-NEXT: File {{[0-9]+}}, 8:16 -> 8:19 = #4
+// CHECK-NEXT: File {{[0-9]+}}, 7:18 -> 7:23 = (#0 + #4)
+// CHECK-NEXT: File {{[0-9]+}}, 6:22 -> 6:27 = #0
+// CHECK-NEXT: File {{[0-9]+}}, 8:16 -> 8:19 = #5
+// CHECK-NEXT: File {{[0-9]+}}, 7:18 -> 7:23 = (#0 + #5)
+// CHECK-NEXT: File {{[0-9]+}}, 4:18 -> 4:22 = (#0 + #6)
+// CHECK-NEXT: File {{[0-9]+}}, 5:20 -> 5:23 = #0
+// CHECK-NEXT: File {{[0-9]+}}, 9:25 -> 9:40 = #0
+// CHECK-NEXT: Expansion,File {{[0-9]+}}, 12:16 -> 12:38 = #8
+// CHECK-NEXT: File {{[0-9]+}}, 12:38 -> 12:42 = #8
+// CHECK-NEXT: File {{[0-9]+}}, 13:16 -> 13:42 = #0
+// CHECK-NEXT: Expansion,File {{[0-9]+}}, 13:16 -> 13:38 = (#0 - #8)
+// CHECK-NEXT: File {{[0-9]+}}, 13:38 -> 13:42 = (#0 - #8)
+// CHECK-NEXT: File {{[0-9]+}}, 11:32 -> 11:36 = #8
+// CHECK-NEXT: File {{[0-9]+}}, 11:32 -> 11:36 = (#0 - #8)
+
+// CHECK-NOT: File {{[0-9]+}},
+// CHECK: main
+
+int main(int argc, const char *argv[]) {
+ foo(10);
+}
OpenPOWER on IntegriCloud