2020-09-03 05:50:32 +08:00
|
|
|
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
|
|
|
|
|
2014-08-20 01:32:30 +08:00
|
|
|
#define MACRO return; bar()
|
|
|
|
#define MACRO_2 bar()
|
|
|
|
#define MACRO_1 return; MACRO_2
|
2016-08-31 15:04:16 +08:00
|
|
|
#define MACRO_3 MACRO_2
|
2018-11-20 04:10:22 +08:00
|
|
|
#define GOTO goto
|
2014-08-20 01:32:30 +08:00
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
void bar() {}
|
|
|
|
|
|
|
|
// CHECK: func
|
|
|
|
void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
int i = 0;
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:8 = #0
|
|
|
|
MACRO; // CHECK-NEXT: File 0, [[@LINE]]:8 -> [[@LINE+2]]:2 = 0
|
|
|
|
i = 2;
|
2014-08-20 01:32:30 +08:00
|
|
|
}
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File 1, 3:15 -> 3:28 = #0
|
|
|
|
// CHECK-NEXT: File 1, 3:23 -> 3:28 = 0
|
2014-08-20 01:32:30 +08:00
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: func2
|
|
|
|
void func2() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+5]]:2 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
int i = 0;
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:10 = #0
|
|
|
|
MACRO_1; // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:2 = 0
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
// CHECK-NEXT: File 1, 5:17 -> 5:32 = #0
|
|
|
|
// CHECK-NEXT: Expansion,File 1, 5:25 -> 5:32 = 0
|
|
|
|
// CHECK-NEXT: File 2, 4:17 -> 4:22 = 0
|
|
|
|
|
|
|
|
// CHECK-NEXT: func3
|
|
|
|
void func3() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+3]]:2 = #0
|
|
|
|
MACRO_2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:10 = #0
|
|
|
|
MACRO_2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:10 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
}
|
2015-02-19 05:24:51 +08:00
|
|
|
// CHECK-NEXT: File 1, 4:17 -> 4:22 = #0
|
|
|
|
// CHECK-NEXT: File 2, 4:17 -> 4:22 = #0
|
2014-08-20 01:32:30 +08:00
|
|
|
|
2016-08-29 19:48:50 +08:00
|
|
|
// CHECK-NEXT: func4
|
2021-02-18 10:16:40 +08:00
|
|
|
void func4() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+8]]:2 = #0
|
2016-08-29 19:48:50 +08:00
|
|
|
int i = 0;
|
|
|
|
while (i++ < 10) // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:18 = (#0 + #1)
|
2021-02-18 10:16:40 +08:00
|
|
|
if (i < 5) // CHECK: File 0, [[@LINE]]:5 -> [[@LINE+4]]:14 = #1
|
2016-08-29 19:48:50 +08:00
|
|
|
// CHECK-NEXT: File 0, [[@LINE-1]]:9 -> [[@LINE-1]]:14 = #1
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE-2]]:9 -> [[@LINE-2]]:14 = #2, (#1 - #2)
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE-3]]:15 -> [[@LINE+1]]:7 = #2
|
2016-08-29 19:48:50 +08:00
|
|
|
MACRO_2; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:7 -> [[@LINE]]:14 = #2
|
|
|
|
}
|
|
|
|
// CHECK-NEXT: File 1, 4:17 -> 4:22 = #2
|
|
|
|
// CHECK-NOT: File 1
|
|
|
|
|
2016-08-31 15:04:16 +08:00
|
|
|
// CHECK-NEXT: func5
|
2021-02-18 10:16:40 +08:00
|
|
|
void func5() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+6]]:2 = #0
|
2016-08-31 15:04:16 +08:00
|
|
|
int i = 0;
|
|
|
|
if (i > 5) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = #0
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:12 = #1, (#0 - #1)
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:13 -> [[@LINE+1]]:5 = #1
|
2016-08-31 15:04:16 +08:00
|
|
|
MACRO_3; // CHECK-NEXT: Expansion,File 0, [[@LINE]]:5 -> [[@LINE]]:12 = #1
|
|
|
|
}
|
|
|
|
// CHECK-NEXT: Expansion,File 1, 6:17 -> 6:24 = #1
|
|
|
|
// CHECK-NEXT: File 2, 4:17 -> 4:22 = #1
|
|
|
|
|
2018-11-20 04:10:22 +08:00
|
|
|
// CHECK-NEXT: func6
|
2021-02-18 10:16:40 +08:00
|
|
|
void func6(unsigned count) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+6]]:2 = #0
|
|
|
|
begin: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+5]]:2 = #1
|
2018-11-20 04:10:22 +08:00
|
|
|
if (count--) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:16 = #1
|
2020-12-29 01:20:48 +08:00
|
|
|
// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:9 -> [[@LINE-1]]:16 = #2, (#1 - #2)
|
2021-02-18 10:16:40 +08:00
|
|
|
// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE+1]]:9 = #2
|
2018-11-20 04:10:22 +08:00
|
|
|
GOTO begin; // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:19 = #2
|
|
|
|
}
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE-2]]:9 -> [[@LINE-2]]:13 = #2
|
|
|
|
// CHECK-NEXT: File 1, 7:14 -> 7:18 = #2
|
|
|
|
|
2021-02-18 10:16:40 +08:00
|
|
|
// Regression test for gap region between macros.
|
|
|
|
// CHECK-NEXT: func7
|
|
|
|
int k, l;
|
|
|
|
#define m(e) e##e
|
|
|
|
void func7() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+6]]:2 = #0
|
|
|
|
int kk,ll; // CHECK-NEXT: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:8 = #0
|
|
|
|
if (k) // CHECK-NEXT: Branch,File 0, [[@LINE]]:7 -> [[@LINE]]:8 = #1
|
|
|
|
m(k); // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:9 -> [[@LINE]]:5 = #1
|
|
|
|
else // CHECK-NEXT: Expansion,File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:6 = #0
|
|
|
|
l = m(l); // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:7 -> [[@LINE]]:5 = (#0 - #1)
|
|
|
|
} // CHECK-NEXT: File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:10 = (#0 - #1)
|
|
|
|
// CHECK-NEXT: Expansion,File 0, [[@LINE-2]]:9 -> [[@LINE-2]]:10 = (#0 - #1)
|
|
|
|
// CHECK-NEXT: File 1, [[@LINE-9]]:14 -> [[@LINE-9]]:18 = #0
|
|
|
|
// CHECK-NEXT: File 2, [[@LINE-10]]:14 -> [[@LINE-10]]:15 = (#0 - #1)
|
|
|
|
|
2015-02-19 05:24:51 +08:00
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
func();
|
|
|
|
func2();
|
|
|
|
func3();
|
2016-08-29 19:48:50 +08:00
|
|
|
func4();
|
2015-02-19 05:24:51 +08:00
|
|
|
}
|