
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
76 lines
3.3 KiB
C++
76 lines
3.3 KiB
C++
// 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);
|
|
}
|