| 1 |
// RUN: %clang_cc1 -triple x86_64-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple x86_64-darwin -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s --check-prefix=EXCEPTIONS |
| 3 |
|
| 4 |
// PR36748 |
| 5 |
|
| 6 |
// Classes to verify order of destroying function parameters. |
| 7 |
struct S1 { |
| 8 |
~S1(); |
| 9 |
}; |
| 10 |
struct S2 { |
| 11 |
~S2(); |
| 12 |
}; |
| 13 |
|
| 14 |
struct Base { |
| 15 |
// Use variadic args to cause inlining the inherited constructor. |
| 16 |
Base(const S1&, const S2&, const char *fmt, ...) {} |
| 17 |
}; |
| 18 |
|
| 19 |
struct NonTrivialDtor { |
| 20 |
~NonTrivialDtor() {} |
| 21 |
}; |
| 22 |
struct Inheritor : public NonTrivialDtor, public Base { |
| 23 |
using Base::Base; |
| 24 |
}; |
| 25 |
|
| 26 |
void f() { |
| 27 |
Inheritor(S1(), S2(), "foo"); |
| 28 |
// CHECK-LABEL: define{{.*}} void @_Z1fv |
| 29 |
// CHECK: %[[TMP1:.*]] = alloca %struct.S1 |
| 30 |
// CHECK: %[[TMP2:.*]] = alloca %struct.S2 |
| 31 |
// CHECK: call void (ptr, ptr, ptr, ptr, ...) @_ZN4BaseC2ERK2S1RK2S2PKcz(ptr {{.*}}, ptr noundef nonnull align 1 dereferenceable(1) %[[TMP1]], ptr noundef nonnull align 1 dereferenceable(1) %[[TMP2]], ptr {{.*}}) |
| 32 |
// CHECK-NEXT: call void @_ZN9InheritorD1Ev(ptr {{.*}}) |
| 33 |
// CHECK-NEXT: call void @_ZN2S2D1Ev(ptr {{[^,]*}} %[[TMP2]]) |
| 34 |
// CHECK-NEXT: call void @_ZN2S1D1Ev(ptr {{[^,]*}} %[[TMP1]]) |
| 35 |
|
| 36 |
// EXCEPTIONS-LABEL: define{{.*}} void @_Z1fv |
| 37 |
// EXCEPTIONS: %[[TMP1:.*]] = alloca %struct.S1 |
| 38 |
// EXCEPTIONS: %[[TMP2:.*]] = alloca %struct.S2 |
| 39 |
// EXCEPTIONS: invoke void (ptr, ptr, ptr, ptr, ...) @_ZN4BaseC2ERK2S1RK2S2PKcz(ptr {{.*}}, ptr noundef nonnull align 1 dereferenceable(1) %[[TMP1]], ptr noundef nonnull align 1 dereferenceable(1) %[[TMP2]], ptr {{.*}}) |
| 40 |
// EXCEPTIONS-NEXT: to label %[[CONT:.*]] unwind label %[[LPAD:.*]] |
| 41 |
|
| 42 |
// EXCEPTIONS: [[CONT]]: |
| 43 |
// EXCEPTIONS-NEXT: call void @_ZN9InheritorD1Ev(ptr {{.*}}) |
| 44 |
// EXCEPTIONS-NEXT: call void @_ZN2S2D1Ev(ptr {{[^,]*}} %[[TMP2]]) |
| 45 |
// EXCEPTIONS-NEXT: call void @_ZN2S1D1Ev(ptr {{[^,]*}} %[[TMP1]]) |
| 46 |
|
| 47 |
// EXCEPTIONS: [[LPAD]]: |
| 48 |
// EXCEPTIONS: call void @_ZN14NonTrivialDtorD2Ev(ptr {{.*}}) |
| 49 |
// EXCEPTIONS-NEXT: call void @_ZN2S2D1Ev(ptr {{[^,]*}} %[[TMP2]]) |
| 50 |
// EXCEPTIONS-NEXT: call void @_ZN2S1D1Ev(ptr {{[^,]*}} %[[TMP1]]) |
| 51 |
} |