[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / switch-case-folding-2.cpp
blobb46b983c5cc9621541e8e4514026255653e2c221
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 extern int printf(const char*, ...);
5 // CHECK-LABEL: @_Z4testi(
6 int test(int val){
7 switch (val) {
8 case 4:
9 do {
10 switch (6) {
11 // CHECK: call noundef i32 (ptr, ...) @_Z6printfPKcz
12 case 6: do { case 5: printf("bad\n"); } while (0);
14 } while (0);
16 return 0;
19 int main(void) {
20 return test(5);
23 // CHECK-LABEL: @_Z10other_testv(
24 void other_test() {
25 switch(0) {
26 case 0:
27 do {
28 default:;
29 } while(0);
33 struct X { X(); ~X(); };
35 void dont_call();
36 void foo();
38 // CHECK-LABEL: @_Z13nested_scopesv(
39 void nested_scopes() {
40 switch (1) {
41 case 0:
42 // CHECK-NOT: @_Z9dont_callv(
43 dont_call();
44 break;
46 default:
47 // CHECK: call {{.*}} @_ZN1XC1Ev(
48 // CHECK: call {{.*}} @_Z3foov(
49 // CHECK-NOT: call {{.*}} @_Z3foov(
50 // CHECK: call {{.*}} @_ZN1XD1Ev(
51 { X x; foo(); }
53 // CHECK: call {{.*}} @_ZN1XC1Ev(
54 // CHECK: call {{.*}} @_Z3foov(
55 // CHECK: call {{.*}} @_ZN1XD1Ev(
56 { X x; foo(); }
58 // CHECK: call {{.*}} @_ZN1XC1Ev(
59 // CHECK: call {{.*}} @_Z3foov(
60 // CHECK: call {{.*}} @_ZN1XD1Ev(
61 { X x; foo(); }
62 break;
66 // CHECK-LABEL: @_Z17scope_fallthroughv(
67 void scope_fallthrough() {
68 switch (1) {
69 // CHECK: call {{.*}} @_ZN1XC1Ev(
70 // CHECK-NOT: call {{.*}} @_Z3foov(
71 // CHECK: call {{.*}} @_ZN1XD1Ev(
72 { default: X x; }
73 // CHECK: call {{.*}} @_Z3foov(
74 foo();
75 break;
79 // CHECK-LABEL: @_Z12hidden_breakb(
80 void hidden_break(bool b) {
81 switch (1) {
82 default:
83 // CHECK: br
84 if (b)
85 break;
86 // CHECK: call {{.*}} @_Z3foov(
87 foo();
88 break;
92 // CHECK-LABEL: @_Z10hidden_varv(
93 int hidden_var() {
94 switch (1) {
95 // CHECK: %[[N:.*]] = alloca i32
96 case 0: int n;
97 // CHECK: store i32 0, ptr %[[N]]
98 // CHECK: load i32, ptr %[[N]]
99 // CHECK: ret
100 default: n = 0; return n;
104 // CHECK-LABEL: @_Z13case_in_labelv(
105 void case_in_label() {
106 // CHECK: br label %
107 switch (1) case 1: foo: case 0: goto foo;