xref: /llvm-project/clang/test/CoverageMapping/md.cpp (revision 9caa3fbe03f43e3eec30262fbba87c1ee15c05a3)
1*9caa3fbeSZequan Wu // RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++11 %s | FileCheck %s
2bf42cfd7SJustin Bogner 
3bf42cfd7SJustin Bogner #define BREAK break
4bf42cfd7SJustin Bogner 
5bf42cfd7SJustin Bogner enum class MD {
6bf42cfd7SJustin Bogner   Val1,
7bf42cfd7SJustin Bogner   Val2
8bf42cfd7SJustin Bogner };
9bf42cfd7SJustin Bogner 
nop()10bf42cfd7SJustin Bogner void nop() {}
11bf42cfd7SJustin Bogner 
12bf42cfd7SJustin Bogner // CHECK: foo
13bf42cfd7SJustin Bogner // CHECK-NEXT: File 0, [[@LINE+1]]:16 -> {{[0-9]+}}:2 = #0
foo(MD i)14bf42cfd7SJustin Bogner void foo(MD i) {
15bf42cfd7SJustin Bogner   switch (i) {
16bf42cfd7SJustin Bogner   #define HANDLE_MD(X)                                          \
17bf42cfd7SJustin Bogner   case MD::X:                                                   \
18bf42cfd7SJustin Bogner     break;
19bf42cfd7SJustin Bogner   #include "Inputs/md.def"
20bf42cfd7SJustin Bogner   default:
21bf42cfd7SJustin Bogner     BREAK;
22bf42cfd7SJustin Bogner   }
23bf42cfd7SJustin Bogner 
24bf42cfd7SJustin Bogner   if (false)
25bf42cfd7SJustin Bogner     nop();
26bf42cfd7SJustin Bogner   #define HANDLE_MD(X) else if (i == MD::X) { nop(); }
27bf42cfd7SJustin Bogner   #include "Inputs/md.def"
28bf42cfd7SJustin Bogner }
29bf42cfd7SJustin Bogner 
30181dfe4cSEli Friedman // CHECK: bar
31181dfe4cSEli Friedman // CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
32181dfe4cSEli Friedman bool isVal1();
33181dfe4cSEli Friedman bool isVal2();
bar()34181dfe4cSEli Friedman bool bar() {
35181dfe4cSEli Friedman  #define HANDLE_MD(X) is##X() ||
36181dfe4cSEli Friedman   return
37181dfe4cSEli Friedman #include "Inputs/md.def"
38181dfe4cSEli Friedman   0;
39181dfe4cSEli Friedman }
40181dfe4cSEli Friedman 
main(int argc,const char * argv[])41bf42cfd7SJustin Bogner int main(int argc, const char *argv[]) {
42bf42cfd7SJustin Bogner   foo(MD::Val1);
43bf42cfd7SJustin Bogner   return 0;
44bf42cfd7SJustin Bogner }
45