Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -std=c++11 -o - %s | FileCheck %s
      2 
      3 struct non_trivial {
      4   non_trivial();
      5   ~non_trivial() noexcept(false);
      6 };
      7 non_trivial::non_trivial() {}
      8 non_trivial::~non_trivial() noexcept(false) {}
      9 
     10 // We use a virtual base to ensure that the constructor
     11 // delegation optimization (complete->base) can't be
     12 // performed.
     13 struct delegator {
     14   non_trivial n;
     15   delegator();
     16   delegator(int);
     17   delegator(char);
     18   delegator(bool);
     19 };
     20 
     21 delegator::delegator() {
     22   throw 0;
     23 }
     24 
     25 
     26 delegator::delegator(bool)
     27 {}
     28 
     29 // CHECK: define {{.*}} @_ZN9delegatorC1Ec
     30 // CHECK: {{.*}} @_ZN9delegatorC1Eb
     31 // CHECK: void @__cxa_throw
     32 // CHECK: void @__clang_call_terminate
     33 // CHECK: {{.*}} @_ZN9delegatorD1Ev
     34 // CHECK: define {{.*}} @_ZN9delegatorC2Ec
     35 // CHECK: {{.*}} @_ZN9delegatorC2Eb
     36 // CHECK: void @__cxa_throw
     37 // CHECK: void @__clang_call_terminate
     38 // CHECK: {{.*}} @_ZN9delegatorD2Ev
     39 delegator::delegator(char)
     40   : delegator(true) {
     41   throw 0;
     42 }
     43 
     44 // CHECK: define {{.*}} @_ZN9delegatorC1Ei
     45 // CHECK: {{.*}} @_ZN9delegatorC1Ev
     46 // CHECK-NOT: void @_ZSt9terminatev
     47 // CHECK: ret
     48 // CHECK-NOT: void @_ZSt9terminatev
     49 // CHECK: define {{.*}} @_ZN9delegatorC2Ei
     50 // CHECK: {{.*}} @_ZN9delegatorC2Ev
     51 // CHECK-NOT: void @_ZSt9terminatev
     52 // CHECK: ret
     53 // CHECK-NOT: void @_ZSt9terminatev
     54 delegator::delegator(int)
     55   : delegator()
     56 {}
     57 
     58 namespace PR12890 {
     59   class X {
     60     int x;
     61     X() = default;
     62     X(int);
     63   };
     64   X::X(int) : X() {}
     65 }
     66 // CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32)
     67 // CHECK: call void @llvm.memset.p0i8.{{i32|i64}}(i8* {{.*}}, i8 0, {{i32|i64}} 4, i32 4, i1 false)
     68 
     69 namespace PR14588 {
     70   void other();
     71 
     72   class Base {
     73   public:
     74     Base() { squawk(); }
     75     virtual ~Base() {}
     76 
     77     virtual void squawk() { other(); }
     78   };
     79 
     80 
     81   class Foo : public virtual Base {
     82   public:
     83     Foo();
     84     Foo(const void * inVoid);
     85     virtual ~Foo() {}
     86 
     87     virtual void squawk() { other(); }
     88   };
     89 
     90   // CHECK: define void @_ZN7PR145883FooC1Ev(%"class.PR14588::Foo"*
     91   // CHECK: call void @_ZN7PR145883FooC1EPKv(
     92   // CHECK: invoke void @_ZN7PR145885otherEv()
     93   // CHECK: call void @_ZN7PR145883FooD1Ev
     94   // CHECK: resume
     95 
     96   Foo::Foo() : Foo(__null) { other(); }
     97   Foo::Foo(const void *inVoid) {
     98     squawk();
     99   }
    100 
    101 }
    102