[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Profile / misexpect-branch-cold.c
blob6d34f92a254549a8dacdcc921d05b2688f413794
1 // Test that misexpect emits no warning when prediction is correct
3 // RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
4 // RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
6 // expected-no-diagnostics
7 #define likely(x) __builtin_expect(!!(x), 1)
8 #define unlikely(x) __builtin_expect(!!(x), 0)
10 int foo(int);
11 int baz(int);
12 int buzz();
14 const int inner_loop = 100;
15 const int outer_loop = 2000;
17 int bar() {
18 int rando = buzz();
19 int x = 0;
20 if (unlikely(rando % (outer_loop * inner_loop) == 0)) {
21 x = baz(rando);
22 } else {
23 x = foo(50);
25 return x;