1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
4 extern "C" int printf(...);
7 // CHECK: call i32 (...) @printf({{.*}}, ptr noundef inttoptr (i64 3735928559 to ptr))
8 printf("%p\n", (void *)0xdeadbeef ? : (void *)0xaaaaaa);
11 namespace radar8446940
{
12 extern "C" void abort();
23 namespace radar8453812
{
24 extern "C" void abort();
25 _Complex
int getComplex(_Complex
int val
) {
32 _Complex
int cmplx() {
36 return getComplex(1+2i
) ? : rhs
;
78 // CHECK-LABEL: define{{.*}} void @_ZN5test35test0ERNS_1BE(
79 // CHECK: [[RES:%.*]] = alloca ptr,
80 // CHECK: [[X:%.*]] = alloca ptr,
81 // CHECK: store ptr {{%.*}}, ptr [[RES]]
82 // CHECK: store ptr {{%.*}}, ptr [[X]]
83 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[X]]
84 // CHECK-NEXT: [[BOOL:%.*]] = call noundef zeroext i1 @_ZN5test31BcvbEv(ptr {{[^,]*}} [[T0]])
85 // CHECK-NEXT: br i1 [[BOOL]]
86 // CHECK: call void @_ZN5test31BC1ERKS0_(ptr {{[^,]*}} [[RESULT:%.*]], ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[T0]])
87 // CHECK-NEXT: br label
88 // CHECK: call void @_ZN5test31BC1Ev(ptr {{[^,]*}} [[RESULT]])
89 // CHECK-NEXT: br label
95 // CHECK-LABEL: define{{.*}} void @_ZN5test35test1Ev(
96 // CHECK: [[TEMP:%.*]] = alloca [[B:%.*]],
97 // CHECK: call void @_ZN5test312test1_helperEv(ptr sret([[B]]) align 1 [[TEMP]])
98 // CHECK-NEXT: [[BOOL:%.*]] = call noundef zeroext i1 @_ZN5test31BcvbEv(ptr {{[^,]*}} [[TEMP]])
99 // CHECK-NEXT: br i1 [[BOOL]]
100 // CHECK: call void @_ZN5test31BC1ERKS0_(ptr {{[^,]*}} [[RESULT:%.*]], ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[TEMP]])
101 // CHECK-NEXT: br label
102 // CHECK: call void @_ZN5test31BC1Ev(ptr {{[^,]*}} [[RESULT]])
103 // CHECK-NEXT: br label
104 // CHECK: call void @_ZN5test31BD1Ev(ptr {{[^,]*}} [[TEMP]])
105 // CHECK-NEXT: ret void
106 extern B
test1_helper();
107 return test1_helper() ?: B();
112 // CHECK-LABEL: define{{.*}} void @_ZN5test35test2ERNS_1BE(
113 // CHECK: [[RES:%.*]] = alloca ptr,
114 // CHECK: [[X:%.*]] = alloca ptr,
115 // CHECK: store ptr {{%.*}}, ptr [[RES]]
116 // CHECK: store ptr {{%.*}}, ptr [[X]]
117 // CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[X]]
118 // CHECK-NEXT: [[BOOL:%.*]] = call noundef zeroext i1 @_ZN5test31BcvbEv(ptr {{[^,]*}} [[T0]])
119 // CHECK-NEXT: br i1 [[BOOL]]
120 // CHECK: call void @_ZN5test31BcvNS_1AEEv(ptr sret([[A:%.*]]) align 1 [[RESULT:%.*]], ptr {{[^,]*}} [[T0]])
121 // CHECK-NEXT: br label
122 // CHECK: call void @_ZN5test31AC1Ev(ptr {{[^,]*}} [[RESULT]])
123 // CHECK-NEXT: br label
129 // CHECK-LABEL: define{{.*}} void @_ZN5test35test3Ev(
130 // CHECK: [[TEMP:%.*]] = alloca [[B]],
131 // CHECK: call void @_ZN5test312test3_helperEv(ptr sret([[B]]) align 1 [[TEMP]])
132 // CHECK-NEXT: [[BOOL:%.*]] = call noundef zeroext i1 @_ZN5test31BcvbEv(ptr {{[^,]*}} [[TEMP]])
133 // CHECK-NEXT: br i1 [[BOOL]]
134 // CHECK: call void @_ZN5test31BcvNS_1AEEv(ptr sret([[A]]) align 1 [[RESULT:%.*]], ptr {{[^,]*}} [[TEMP]])
135 // CHECK-NEXT: br label
136 // CHECK: call void @_ZN5test31AC1Ev(ptr {{[^,]*}} [[RESULT]])
137 // CHECK-NEXT: br label
138 // CHECK: call void @_ZN5test31BD1Ev(ptr {{[^,]*}} [[TEMP]])
139 // CHECK-NEXT: ret void
140 extern B
test3_helper();
141 return test3_helper() ?: A();
147 // Make sure this doesn't crash.
149 const int a
= 10, b
= 20;
150 const int *c
= &(a
?: b
);