55 lines · cpp
1// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -std=c++11 |FileCheck %s2 3class x {4public: int operator=(int);5};6void a() {7 x a;8 a = 1u;9}10 11void f(int i, int j) {12 // CHECK: load i3213 // CHECK: load i3214 // CHECK: add nsw i3215 // CHECK: store i3216 // CHECK: store i32 17, ptr17 // CHECK: ret18 (i += j) = 17;19}20 21// Taken from g++.old-deja/g++.jason/net.C22namespace test1 {23 template <class T> void fn (T t) { }24 template <class T> struct A {25 void (*p)(T);26 A() { p = fn; }27 };28 29 A<int> a;30}31 32// Ensure that we use memcpy when we would have selected a trivial assignment33// operator, even for a non-trivially-copyable type.34struct A {35 A &operator=(const A&);36};37struct B {38 B(const B&);39 B &operator=(const B&) = default;40 int n;41};42struct C {43 A a;44 B b[16];45};46void b(C &a, C &b) {47 // CHECK: define {{.*}} @_ZN1CaSERKS_(48 // CHECK: call {{.*}} @_ZN1AaSERKS_(49 // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(50 // CHECK: call {{.*}} @{{.*}}memcpy51 // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(52 // CHECK: }53 a = b;54}55