2020-09-03 05:50:32 +08:00
|
|
|
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp -w %s | FileCheck %s
|
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
#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"
|
|
|
|
|
2016-02-09 03:25:45 +08:00
|
|
|
#define STMT(s) s
|
|
|
|
|
|
|
|
void fn1() {
|
|
|
|
STMT(if (1));
|
|
|
|
STMT(while (1));
|
|
|
|
STMT(for (;;));
|
|
|
|
STMT(if) (1);
|
|
|
|
STMT(while) (1);
|
|
|
|
STMT(for) (;;);
|
|
|
|
if (1)
|
|
|
|
STMT(if (1)
|
|
|
|
STMT(if (1)));
|
|
|
|
if (1)
|
|
|
|
STMT(if (1)) 0;
|
|
|
|
if (1)
|
|
|
|
STMT(while (1)) 0;
|
|
|
|
if (1)
|
|
|
|
STMT(for (;;)) 0;
|
|
|
|
while (1)
|
|
|
|
STMT(if (1)) 0;
|
|
|
|
while (1)
|
|
|
|
STMT(while (1)) 0;
|
|
|
|
while (1)
|
|
|
|
STMT(for (;;)) 0;
|
|
|
|
for (;;)
|
|
|
|
STMT(if (1)) 0;
|
|
|
|
for (;;)
|
|
|
|
STMT(while (1)) 0;
|
|
|
|
for (;;)
|
|
|
|
STMT(for (;;)) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void STMT(fn2()) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void STMT(fn3)() {
|
|
|
|
}
|
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK: foo
|
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:17 -> {{[0-9]+}}:2 = #0
|
|
|
|
void foo(int i) {
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:8 = #0
|
|
|
|
// CHECK: Gap,File 0, [[@LINE+2]]:9 -> [[@LINE+2]]:10 = #1
|
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:12 = #1
|
2015-02-19 05:24:51 +08:00
|
|
|
if (0) {}
|
|
|
|
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:11 = #0
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:16 = #2
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:16 -> [[@LINE+1]]:18 = #2
|
|
|
|
if (EXPR(i)) {}
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:9 -> [[@LINE+3]]:14 = (#0 + #3)
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+2]]:19 -> [[@LINE+2]]:20 = #3
|
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:20 -> [[@LINE+1]]:22 = #3
|
2015-02-19 05:24:51 +08:00
|
|
|
for (;NEXPR(i);) {}
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+5]]:8 -> [[@LINE+5]]:14 = #0
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:33 -> [[@LINE+4]]:35 = (#0 + #4)
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:43 -> [[@LINE+3]]:46 = #4
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+2]]:50 -> [[@LINE+2]]:51 = #4
|
2017-11-30 06:25:14 +08:00
|
|
|
// CHECK: File 0, [[@LINE+1]]:51 -> [[@LINE+1]]:53 = #4
|
2015-02-19 05:24:51 +08:00
|
|
|
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);
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:12 = (#0 + #5)
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:20 = #5
|
2015-02-19 05:24:51 +08:00
|
|
|
// 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));
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+5]]:8 -> [[@LINE+5]]:12 = #0
|
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:21 -> [[@LINE+4]]:22 = #7, #0
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:23 -> [[@LINE+3]]:26 = #0
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+2]]:41 -> [[@LINE+2]]:42 = #7
|
2017-11-30 06:25:14 +08:00
|
|
|
// CHECK: File 0, [[@LINE+1]]:42 -> [[@LINE+1]]:44 = #7
|
2015-02-19 05:24:51 +08:00
|
|
|
for (DECL(int, j) : ARR(int, 1, 2, 3)) {}
|
|
|
|
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+5]]:10 -> [[@LINE+5]]:11 = #0
|
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #8, (#0 - #8)
|
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE+3]]:13 -> [[@LINE+3]]:14 = #8
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:23 -> [[@LINE+1]]:29 = #0
|
|
|
|
(void)(i ? PRIo64 : PRIu64);
|
2015-04-25 07:37:57 +08:00
|
|
|
|
2021-02-03 12:43:13 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+6]]:10 -> [[@LINE+6]]:11 = #0
|
2017-11-09 10:33:38 +08:00
|
|
|
// CHECK: File 0, [[@LINE+5]]:14 -> [[@LINE+5]]:15 = #9
|
2021-02-03 12:43:13 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+4]]:18 -> [[@LINE+4]]:33 = (#0 - #9)
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:18 -> [[@LINE+3]]:22 = (#0 - #9)
|
2017-11-09 10:33:38 +08:00
|
|
|
// CHECK: File 0, [[@LINE+2]]:28 -> [[@LINE+2]]:29 = #10
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:32 -> [[@LINE+1]]:33 = ((#0 - #9) - #10)
|
|
|
|
(void)(i ? i : EXPR(i) ? i : 0);
|
2021-02-03 12:43:13 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+5]]:10 -> [[@LINE+5]]:11 = #0
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #11, (#0 - #11)
|
2021-02-03 12:43:13 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+3]]:15 -> [[@LINE+3]]:27 = (#0 - #11)
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = (#0 - #11)
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:27 = ((#0 - #11) - #12)
|
|
|
|
(void)(i ?: EXPR(i) ?: 0);
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 3:17 -> 3:20 = #0
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 3:17 -> 3:20 = #2, (#0 - #2)
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 4:18 -> 4:22 = (#0 + #3)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 4:18 -> 4:22 = #3, #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// 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)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 7:18 -> 7:23 = #4, #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// 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)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 7:18 -> 7:23 = #5, #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 4:18 -> 4:22 = (#0 + #6)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 4:18 -> 4:22 = #6, #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 5:20 -> 5:23 = #0
|
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 9:25 -> 9:40 = #0
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 12:16 -> 12:42 = #0
|
2015-02-19 05:24:51 +08:00
|
|
|
// 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)
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 3:17 -> 3:20 = (#0 - #9)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 3:17 -> 3:20 = #10, ((#0 - #9) - #10)
|
2015-04-25 07:37:57 +08:00
|
|
|
// CHECK-NEXT: File {{[0-9]+}}, 3:17 -> 3:20 = (#0 - #11)
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File {{[0-9]+}}, 3:17 -> 3:20 = #12, ((#0 - #11) - #12)
|
2015-02-19 05:24:51 +08:00
|
|
|
// 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);
|
|
|
|
}
|