aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-cov/Inputs/branch-templates.cpp
blob: 4d932eaf5944a8c6044beddb722e49b48792d5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38





#include <stdio.h>
template<typename T>
void unused(T x) {
  return;
}

template<typename T>
int func(T x) {
  if(x)       // BRCOV: |  Branch ([[@LINE]]:6): [True: 0, False: 1]
    return 0; // BRCOV: |  Branch ([[@LINE-1]]:6): [True: 1, False: 0]
  else        // BRCOV: |  Branch ([[@LINE-2]]:6): [True: 0, False: 1]
    return 1;
  int j = 1;
}

              // CHECK-LABEL: _Z4funcIiEiT_:
              // BRCOV: |  |  Branch ([[@LINE-8]]:6): [True: 0, False: 1]
              // CHECK-LABEL: _Z4funcIbEiT_:
              // BRCOV: |  |  Branch ([[@LINE-10]]:6): [True: 1, False: 0]
              // CHECK-LABEL: _Z4funcIfEiT_:
              // BRCOV: |  |  Branch ([[@LINE-12]]:6): [True: 0, False: 1]


int main() {
  if (func<int>(0))      // BRCOV: |  Branch ([[@LINE]]:7): [True: 1, False: 0]
    printf("case1\n");
  if (func<bool>(true))  // BRCOV: |  Branch ([[@LINE]]:7): [True: 0, False: 1]
    printf("case2\n");
  if (func<float>(0.0))  // BRCOV: |  Branch ([[@LINE]]:7): [True: 1, False: 0]
    printf("case3\n");
  (void)0;
  return 0;
}