head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.6
	netbsd-11-0-RC3:1.1.1.6
	netbsd-11-0-RC2:1.1.1.6
	netbsd-11-0-RC1:1.1.1.6
	perseant-exfatfs-base-20250801:1.1.1.6
	netbsd-11:1.1.1.6.0.10
	netbsd-11-base:1.1.1.6
	netbsd-10-1-RELEASE:1.1.1.6
	perseant-exfatfs-base-20240630:1.1.1.6
	perseant-exfatfs:1.1.1.6.0.8
	perseant-exfatfs-base:1.1.1.6
	netbsd-8-3-RELEASE:1.1.1.4
	netbsd-9-4-RELEASE:1.1.1.5
	netbsd-10-0-RELEASE:1.1.1.6
	netbsd-10-0-RC6:1.1.1.6
	netbsd-10-0-RC5:1.1.1.6
	netbsd-10-0-RC4:1.1.1.6
	netbsd-10-0-RC3:1.1.1.6
	netbsd-10-0-RC2:1.1.1.6
	netbsd-10-0-RC1:1.1.1.6
	netbsd-10:1.1.1.6.0.6
	netbsd-10-base:1.1.1.6
	netbsd-9-3-RELEASE:1.1.1.5
	cjep_sun2x:1.1.1.6.0.4
	cjep_sun2x-base:1.1.1.6
	cjep_staticlib_x-base1:1.1.1.6
	netbsd-9-2-RELEASE:1.1.1.5
	cjep_staticlib_x:1.1.1.6.0.2
	cjep_staticlib_x-base:1.1.1.6
	netbsd-9-1-RELEASE:1.1.1.5
	phil-wifi-20200421:1.1.1.6
	phil-wifi-20200411:1.1.1.6
	phil-wifi-20200406:1.1.1.6
	netbsd-8-2-RELEASE:1.1.1.4
	netbsd-9-0-RELEASE:1.1.1.5
	netbsd-9-0-RC2:1.1.1.5
	netbsd-9-0-RC1:1.1.1.5
	netbsd-9:1.1.1.5.0.6
	netbsd-9-base:1.1.1.5
	phil-wifi-20190609:1.1.1.5
	netbsd-8-1-RELEASE:1.1.1.4
	netbsd-8-1-RC1:1.1.1.4
	pgoyette-compat-merge-20190127:1.1.1.5
	pgoyette-compat-20190127:1.1.1.5
	pgoyette-compat-20190118:1.1.1.5
	pgoyette-compat-1226:1.1.1.5
	pgoyette-compat-1126:1.1.1.5
	pgoyette-compat-1020:1.1.1.5
	pgoyette-compat-0930:1.1.1.5
	pgoyette-compat-0906:1.1.1.5
	netbsd-7-2-RELEASE:1.1.1.3
	pgoyette-compat-0728:1.1.1.5
	clang-337282:1.1.1.5
	netbsd-8-0-RELEASE:1.1.1.4
	phil-wifi:1.1.1.5.0.4
	phil-wifi-base:1.1.1.5
	pgoyette-compat-0625:1.1.1.5
	netbsd-8-0-RC2:1.1.1.4
	pgoyette-compat-0521:1.1.1.5
	pgoyette-compat-0502:1.1.1.5
	pgoyette-compat-0422:1.1.1.5
	netbsd-8-0-RC1:1.1.1.4
	pgoyette-compat-0415:1.1.1.5
	pgoyette-compat-0407:1.1.1.5
	pgoyette-compat-0330:1.1.1.5
	pgoyette-compat-0322:1.1.1.5
	pgoyette-compat-0315:1.1.1.5
	netbsd-7-1-2-RELEASE:1.1.1.3
	pgoyette-compat:1.1.1.5.0.2
	pgoyette-compat-base:1.1.1.5
	netbsd-7-1-1-RELEASE:1.1.1.3
	clang-319952:1.1.1.5
	matt-nb8-mediatek:1.1.1.4.0.12
	matt-nb8-mediatek-base:1.1.1.4
	clang-309604:1.1.1.5
	perseant-stdc-iso10646:1.1.1.4.0.10
	perseant-stdc-iso10646-base:1.1.1.4
	netbsd-8:1.1.1.4.0.8
	netbsd-8-base:1.1.1.4
	prg-localcount2-base3:1.1.1.4
	prg-localcount2-base2:1.1.1.4
	prg-localcount2-base1:1.1.1.4
	prg-localcount2:1.1.1.4.0.6
	prg-localcount2-base:1.1.1.4
	pgoyette-localcount-20170426:1.1.1.4
	bouyer-socketcan-base1:1.1.1.4
	pgoyette-localcount-20170320:1.1.1.4
	netbsd-7-1:1.1.1.3.0.10
	netbsd-7-1-RELEASE:1.1.1.3
	netbsd-7-1-RC2:1.1.1.3
	clang-294123:1.1.1.4
	netbsd-7-nhusb-base-20170116:1.1.1.3
	bouyer-socketcan:1.1.1.4.0.4
	bouyer-socketcan-base:1.1.1.4
	clang-291444:1.1.1.4
	pgoyette-localcount-20170107:1.1.1.4
	netbsd-7-1-RC1:1.1.1.3
	pgoyette-localcount-20161104:1.1.1.4
	netbsd-7-0-2-RELEASE:1.1.1.3
	localcount-20160914:1.1.1.4
	netbsd-7-nhusb:1.1.1.3.0.8
	netbsd-7-nhusb-base:1.1.1.3
	clang-280599:1.1.1.4
	pgoyette-localcount-20160806:1.1.1.4
	pgoyette-localcount-20160726:1.1.1.4
	pgoyette-localcount:1.1.1.4.0.2
	pgoyette-localcount-base:1.1.1.4
	netbsd-7-0-1-RELEASE:1.1.1.3
	clang-261930:1.1.1.4
	netbsd-7-0:1.1.1.3.0.6
	netbsd-7-0-RELEASE:1.1.1.3
	netbsd-7-0-RC3:1.1.1.3
	netbsd-7-0-RC2:1.1.1.3
	netbsd-7-0-RC1:1.1.1.3
	clang-237755:1.1.1.3
	clang-232565:1.1.1.3
	clang-227398:1.1.1.3
	tls-maxphys-base:1.1.1.3
	tls-maxphys:1.1.1.3.0.4
	netbsd-7:1.1.1.3.0.2
	netbsd-7-base:1.1.1.3
	clang-215315:1.1.1.3
	clang-209886:1.1.1.3
	yamt-pagecache:1.1.1.2.0.4
	yamt-pagecache-base9:1.1.1.2
	tls-earlyentropy:1.1.1.2.0.2
	tls-earlyentropy-base:1.1.1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	clang-202566:1.1.1.2
	clang-201163:1.1.1.2
	clang-199312:1.1.1.2
	clang-198450:1.1.1.2
	clang-196603:1.1.1.1
	clang-195771:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2013.11.28.14.14.58;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	ow8OybrawrB1f3fx;

1.1.1.1
date	2013.11.28.14.14.58;	author joerg;	state Exp;
branches;
next	1.1.1.2;
commitid	ow8OybrawrB1f3fx;

1.1.1.2
date	2014.01.05.15.40.04;	author joerg;	state Exp;
branches
	1.1.1.2.2.1
	1.1.1.2.4.1;
next	1.1.1.3;
commitid	wh3aCSIWykURqWjx;

1.1.1.3
date	2014.05.30.18.14.47;	author joerg;	state Exp;
branches
	1.1.1.3.4.1;
next	1.1.1.4;
commitid	8q0kdlBlCn09GACx;

1.1.1.4
date	2016.02.27.22.10.23;	author joerg;	state Exp;
branches;
next	1.1.1.5;
commitid	tIimz3oDlh1NpBWy;

1.1.1.5
date	2017.08.01.19.34.20;	author joerg;	state Exp;
branches
	1.1.1.5.4.1;
next	1.1.1.6;
commitid	pMuDy65V0VicSx1A;

1.1.1.6
date	2019.11.13.22.20.14;	author joerg;	state dead;
branches;
next	;
commitid	QD8YATxuNG34YJKB;

1.1.1.2.2.1
date	2014.08.10.07.08.14;	author tls;	state Exp;
branches;
next	;
commitid	t01A1TLTYxkpGMLx;

1.1.1.2.4.1
date	2014.01.05.15.40.04;	author yamt;	state dead;
branches;
next	1.1.1.2.4.2;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.2.4.2
date	2014.05.22.16.18.55;	author yamt;	state Exp;
branches;
next	;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.3.4.1
date	2014.05.30.18.14.47;	author tls;	state dead;
branches;
next	1.1.1.3.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.3.4.2
date	2014.08.19.23.47.56;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.5.4.1
date	2020.04.13.07.47.28;	author martin;	state dead;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s

struct Member { int x; Member(); Member(int); Member(const Member &); };
struct VBase { int x; VBase(); VBase(int); VBase(const VBase &); };

struct ValueClass {
  ValueClass(int x, int y) : x(x), y(y) {}
  int x;
  int y;
}; // subject to ABI trickery



/* Test basic functionality. */
struct A {
  A(struct Undeclared &);
  A(ValueClass);
  Member mem;
};

A::A(struct Undeclared &ref) : mem(0) {}

// Check that delegation works.
// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(

// CHECK-LABEL: define void @@_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

A::A(ValueClass v) : mem(v.y - v.x) {}

// CHECK-LABEL: define void @@_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN1AC2E10ValueClass(

// CHECK-LABEL: define void @@_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(


/* Test that things work for inheritance. */
struct B : A {
  B(struct Undeclared &);
  Member mem;
};

B::B(struct Undeclared &ref) : A(ref), mem(1) {}

// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1BC2ER10Undeclared(

// CHECK-LABEL: define void @@_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(
// CHECK: call void @@_ZN6MemberC1Ei(



/* Test that the delegation optimization is disabled for classes with
   virtual bases (for now).  This is necessary because a vbase
   initializer could access one of the parameter variables by
   reference.  That's a solvable problem, but let's not solve it right
   now. */
struct C : virtual A {
  C(int);
  Member mem;
};
C::C(int x) : A(ValueClass(x, x+1)), mem(x * x) {}

// CHECK-LABEL: define void @@_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(



/* Test that the delegation optimization is disabled for varargs
   constructors. */
struct D : A {
  D(int, ...);
  Member mem;
};

D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {}

// CHECK-LABEL: define void @@_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(


// PR6622:  this shouldn't crash
namespace test0 {
  struct A {};
  struct B : virtual A { int x; };
  struct C : B {};
  
  void test(C &in) {
    C tmp = in;
  }
}

namespace test1 {
  struct A { A(); void *ptr; };
  struct B { B(); int x; A a[0]; };
  B::B() {}
  // CHECK-LABEL:    define void @@_ZN5test11BC2Ev(
  // CHECK:      [[THIS:%.*]] = load [[B:%.*]]**
  // CHECK-NEXT: ret void
}
@


1.1.1.1
log
@Import Clang 3.4rc1 r195771.
@
text
@@


1.1.1.2
log
@Import clang 3.5svn r198450.
@
text
@d24 3
d30 1
a30 2
// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(
d32 2
a33 1
A::A(ValueClass v) : mem(v.y - v.x) {}
a37 2
// CHECK-LABEL: define void @@_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN1AC2E10ValueClass(
d47 3
a53 2
// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1BC2ER10Undeclared(
a66 3
// CHECK-LABEL: define void @@_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

d72 4
d86 1
a86 1
// CHECK-LABEL: define void @@_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
d91 1
a91 1
// CHECK-LABEL: define void @@_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
d96 1
@


1.1.1.2.2.1
log
@Rebase.
@
text
@d24 1
a24 1
// CHECK-LABEL: define void @@_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d27 1
a27 1
// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d46 1
a46 1
// CHECK-LABEL: define void @@_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d50 1
a50 1
// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
@


1.1.1.3
log
@Import Clang 3.5svn r209886.
@
text
@d24 1
a24 1
// CHECK-LABEL: define void @@_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d27 1
a27 1
// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d46 1
a46 1
// CHECK-LABEL: define void @@_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
d50 1
a50 1
// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
@


1.1.1.4
log
@Import Clang 3.8.0rc3 r261930.
@
text
@d109 1
a109 1
  // CHECK:      [[THIS:%.*]] = load [[B:%.*]]*, [[B:%.*]]**
@


1.1.1.5
log
@Import clang r309604 from branches/release_50
@
text
@d1 1
a1 1
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_appear_in_output
a111 54

// Ensure that we
// a) emit the ABI-required but useless complete object and deleting destructor
//    symbols for an abstract class, and 
// b) do *not* emit references to virtual base destructors for an abstract class
//
// Our approach to this is to give these functions a body that simply traps.
//
// FIXME: We should ideally not create these symbols at all, but Clang can
// actually generate references to them in other TUs in some cases, so we can't
// stop emitting them without breaking ABI. See:
//
//   https://github.com/itanium-cxx-abi/cxx-abi/issues/10
namespace abstract {
  // Note, the destructor of this class is not instantiated here.
  template<typename T> struct should_not_appear_in_output {
    ~should_not_appear_in_output() { int arr[-(int)sizeof(T)]; }
  };

  struct X { ~X(); };

  struct A : virtual should_not_appear_in_output<int>, X {
    virtual ~A() = 0;
  };

  // CHECK-LABEL: define void @@_ZN8abstract1AD2Ev(
  // CHECK: call {{.*}}@@_ZN8abstract1XD2Ev(
  // CHECK: ret

  // CHECK-LABEL: define void @@_ZN8abstract1AD1Ev(
  // CHECK: call {{.*}}@@llvm.trap(
  // CHECK: unreachable

  // CHECK-LABEL: define void @@_ZN8abstract1AD0Ev(
  // CHECK: call {{.*}}@@llvm.trap(
  // CHECK: unreachable
  A::~A() {}

  struct B : virtual should_not_appear_in_output<int>, X {
    virtual void f() = 0;
    ~B();
  };

  // CHECK-LABEL: define void @@_ZN8abstract1BD2Ev(
  // CHECK: call {{.*}}@@_ZN8abstract1XD2Ev(
  // CHECK: ret

  // CHECK-LABEL: define void @@_ZN8abstract1BD1Ev(
  // CHECK: call {{.*}}@@llvm.trap(
  // CHECK: unreachable

  // CHECK-NOT: @@_ZN8abstract1BD0Ev(
  B::~B() {}
}
@


1.1.1.5.4.1
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.6
log
@Mark old LLVM instance as dead.
@
text
@@


1.1.1.3.4.1
log
@file constructors.cpp was added on branch tls-maxphys on 2014-08-19 23:47:56 +0000
@
text
@d1 111
@


1.1.1.3.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 111
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s

struct Member { int x; Member(); Member(int); Member(const Member &); };
struct VBase { int x; VBase(); VBase(int); VBase(const VBase &); };

struct ValueClass {
  ValueClass(int x, int y) : x(x), y(y) {}
  int x;
  int y;
}; // subject to ABI trickery



/* Test basic functionality. */
struct A {
  A(struct Undeclared &);
  A(ValueClass);
  Member mem;
};

A::A(struct Undeclared &ref) : mem(0) {}

// Check that delegation works.
// CHECK-LABEL: define void @@_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(

A::A(ValueClass v) : mem(v.y - v.x) {}

// CHECK-LABEL: define void @@_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN1AC2E10ValueClass(

/* Test that things work for inheritance. */
struct B : A {
  B(struct Undeclared &);
  Member mem;
};

B::B(struct Undeclared &ref) : A(ref), mem(1) {}

// CHECK-LABEL: define void @@_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* nonnull %ref) unnamed_addr
// CHECK: call void @@_ZN1BC2ER10Undeclared(


/* Test that the delegation optimization is disabled for classes with
   virtual bases (for now).  This is necessary because a vbase
   initializer could access one of the parameter variables by
   reference.  That's a solvable problem, but let's not solve it right
   now. */
struct C : virtual A {
  C(int);
  Member mem;
};
C::C(int x) : A(ValueClass(x, x+1)), mem(x * x) {}

// CHECK-LABEL: define void @@_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(


/* Test that the delegation optimization is disabled for varargs
   constructors. */
struct D : A {
  D(int, ...);
  Member mem;
};

D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {}

// CHECK-LABEL: define void @@_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// PR6622:  this shouldn't crash
namespace test0 {
  struct A {};
  struct B : virtual A { int x; };
  struct C : B {};
  
  void test(C &in) {
    C tmp = in;
  }
}

namespace test1 {
  struct A { A(); void *ptr; };
  struct B { B(); int x; A a[0]; };
  B::B() {}
  // CHECK-LABEL:    define void @@_ZN5test11BC2Ev(
  // CHECK:      [[THIS:%.*]] = load [[B:%.*]]**
  // CHECK-NEXT: ret void
}
@


1.1.1.2.4.1
log
@file constructors.cpp was added on branch yamt-pagecache on 2014-05-22 16:18:55 +0000
@
text
@d1 111
@


1.1.1.2.4.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 111
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s

struct Member { int x; Member(); Member(int); Member(const Member &); };
struct VBase { int x; VBase(); VBase(int); VBase(const VBase &); };

struct ValueClass {
  ValueClass(int x, int y) : x(x), y(y) {}
  int x;
  int y;
}; // subject to ABI trickery



/* Test basic functionality. */
struct A {
  A(struct Undeclared &);
  A(ValueClass);
  Member mem;
};

A::A(struct Undeclared &ref) : mem(0) {}

// Check that delegation works.
// CHECK-LABEL: define void @@_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(

A::A(ValueClass v) : mem(v.y - v.x) {}

// CHECK-LABEL: define void @@_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
// CHECK: call void @@_ZN1AC2E10ValueClass(

/* Test that things work for inheritance. */
struct B : A {
  B(struct Undeclared &);
  Member mem;
};

B::B(struct Undeclared &ref) : A(ref), mem(1) {}

// CHECK-LABEL: define void @@_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1AC2ER10Undeclared(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
// CHECK: call void @@_ZN1BC2ER10Undeclared(


/* Test that the delegation optimization is disabled for classes with
   virtual bases (for now).  This is necessary because a vbase
   initializer could access one of the parameter variables by
   reference.  That's a solvable problem, but let's not solve it right
   now. */
struct C : virtual A {
  C(int);
  Member mem;
};
C::C(int x) : A(ValueClass(x, x+1)), mem(x * x) {}

// CHECK-LABEL: define void @@_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(


/* Test that the delegation optimization is disabled for varargs
   constructors. */
struct D : A {
  D(int, ...);
  Member mem;
};

D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {}

// CHECK-LABEL: define void @@_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// CHECK-LABEL: define void @@_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
// CHECK: call void @@_ZN10ValueClassC1Eii(
// CHECK: call void @@_ZN1AC2E10ValueClass(
// CHECK: call void @@_ZN6MemberC1Ei(

// PR6622:  this shouldn't crash
namespace test0 {
  struct A {};
  struct B : virtual A { int x; };
  struct C : B {};
  
  void test(C &in) {
    C tmp = in;
  }
}

namespace test1 {
  struct A { A(); void *ptr; };
  struct B { B(); int x; A a[0]; };
  B::B() {}
  // CHECK-LABEL:    define void @@_ZN5test11BC2Ev(
  // CHECK:      [[THIS:%.*]] = load [[B:%.*]]**
  // CHECK-NEXT: ret void
}
@


