Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
      2 
      3 struct T {
      4   T();
      5   ~T();
      6 };
      7 
      8 void f(const T& t = T());
      9 
     10 class X { // ...
     11 public:
     12         X();
     13         X(const X&, const T& t = T());
     14 };
     15 
     16 // CHECK: define void @_Z1gv()
     17 void g() {
     18   // CHECK:      call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]])
     19   // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG1]])
     20   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]])
     21   f();
     22 
     23   // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]])
     24   // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG2]])
     25   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]])
     26   f();
     27 
     28   // CHECK-NEXT: call void @_ZN1XC1Ev(
     29   X a;
     30 
     31   // CHECK-NEXT: call void @_ZN1TC1Ev(
     32   // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
     33   // CHECK-NEXT: call void @_ZN1TD1Ev(
     34   X b(a);
     35 
     36   // CHECK-NEXT: call void @_ZN1TC1Ev(
     37   // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
     38   // CHECK-NEXT: call void @_ZN1TD1Ev(
     39   X c = a;
     40 }
     41 
     42 
     43 class obj{ int a; float b; double d; };
     44 // CHECK: define void @_Z1hv()
     45 void h() {
     46   // CHECK: call void @llvm.memset.p0i8.i64(
     47   obj o = obj();
     48 }
     49 
     50 // PR7028 - mostly this shouldn't crash
     51 namespace test1 {
     52   struct A { A(); };
     53   struct B { B(); ~B(); };
     54 
     55   struct C {
     56     C(const B &file = B());
     57   };
     58   C::C(const B &file) {}
     59 
     60   struct D {
     61     C c;
     62     A a;
     63 
     64     // CHECK: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr
     65     // CHECK:      call void @_ZN5test11BC1Ev(
     66     // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE(
     67     // CHECK-NEXT: call void @_ZN5test11BD1Ev(
     68     // CHECK:      call void @_ZN5test11AC1Ev(
     69     D() : c(), a() {}
     70   };
     71 
     72   D d;
     73 }
     74