Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -std=c++11 |FileCheck %s
      2 
      3 class x {
      4 public: int operator=(int);
      5 };
      6 void a() {
      7   x a;
      8   a = 1u;
      9 }
     10 
     11 void f(int i, int j) {
     12   // CHECK: load i32
     13   // CHECK: load i32
     14   // CHECK: add nsw i32
     15   // CHECK: store i32
     16   // CHECK: store i32 17, i32
     17   // CHECK: ret
     18   (i += j) = 17;
     19 }
     20 
     21 // Taken from g++.old-deja/g++.jason/net.C
     22 namespace 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 assignment
     33 // operator, even for a non-trivially-copyable type.
     34 struct A {
     35   A &operator=(const A&);
     36 };
     37 struct B {
     38   B(const B&);
     39   B &operator=(const B&) = default;
     40   int n;
     41 };
     42 struct C {
     43   A a;
     44   B b[16];
     45 };
     46 void b(C &a, C &b) {
     47   // CHECK: define {{.*}} @_ZN1CaSERKS_(
     48   // CHECK: call {{.*}} @_ZN1AaSERKS_(
     49   // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(
     50   // CHECK: call {{.*}} @{{.*}}memcpy
     51   // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(
     52   // CHECK: }
     53   a = b;
     54 }
     55