1 // RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s 2 3 struct A { int a, b; int f(); }; 4 5 namespace NonAggregateCopyInAggregateInit { // PR32044 6 struct A { constexpr A(int n) : x(n), y() {} int x, y; } extern a; 7 // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1bE = global %{{.*}} { %[[A:.*]]* @_ZN31NonAggregateCopyInAggregateInit1aE } 8 struct B { A &p; } b{{a}}; 9 // CHECK-DAG: @_ZGRN31NonAggregateCopyInAggregateInit1cE_ = internal global %[[A]] { i32 1, i32 0 } 10 // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1cE = global %{{.*}} { %{{.*}}* @_ZGRN31NonAggregateCopyInAggregateInit1cE_ } 11 struct C { A &&p; } c{{1}}; 12 } 13 14 // CHECK-LABEL: define {{.*}}@_Z3fn1i( 15 int fn1(int x) { 16 // CHECK: %[[INITLIST:.*]] = alloca %struct.A 17 // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 0 18 // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4 19 // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 1 20 // CHECK: store i32 5, i32* %[[B]], align 4 21 // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]]) 22 return A{x, 5}.f(); 23 } 24 25 struct B { int &r; int &f() { return r; } }; 26 27 // CHECK-LABEL: define {{.*}}@_Z3fn2Ri( 28 int &fn2(int &v) { 29 // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 30 // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B, %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 31 // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8 32 // CHECK: call dereferenceable({{[0-9]+}}) i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]]) 33 return B{v}.f(); 34 } 35 36 // CHECK-LABEL: define {{.*}}@__cxx_global_var_init( 37 // 38 // CHECK: call {{.*}}@_ZN14NonTrivialInit1AC1Ev( 39 // CHECK: getelementptr inbounds {{.*}}, i64 1 40 // CHECK: br i1 41 // 42 // CHECK: getelementptr inbounds {{.*}}, i64 1 43 // CHECK: icmp eq {{.*}}, i64 30 44 // CHECK: br i1 45 // 46 // CHECK: call i32 @__cxa_atexit( 47 namespace NonTrivialInit { 48 struct A { A(); A(const A&) = delete; ~A(); }; 49 struct B { A a[20]; }; 50 // NB, this must be large enough to be worth memsetting for this test to be 51 // meaningful. 52 B b[30] = {}; 53 } 54