brintos

brintos / llvm-project-archived public Read only

0
0
Text · 955 B · ef0f124 Raw
37 lines · c
1// Test that misexpect emits no warning when there is only one switch case2 3// RUN: llvm-profdata merge %S/Inputs/misexpect-switch-default-only.proftext -o %t.profdata4// RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect -debug-info-kind=line-tables-only5 6// expected-no-diagnostics7 8#define inner_loop 10009#define outer_loop 2010#define arry_size 2511 12int sum(int *buff, int size);13int random_sample(int *buff, int size);14int rand();15void init_arry();16 17int arry[arry_size] = {0};18 19int main() {20  init_arry();21  int val = 0;22 23  int j, k;24  for (j = 0; j < outer_loop; ++j) {25    for (k = 0; k < inner_loop; ++k) {26      unsigned condition = rand() % 10000;27      switch (__builtin_expect(condition, 0)) {28      default:29        val += random_sample(arry, arry_size);30        break;31      }; // end switch32    }    // end inner_loop33  }      // end outer_loop34 35  return 0;36}37