blob: f435560c975989b5f90863df26c60aa1420f19a2 [file] [log] [blame]
Tim Shen421119f2016-07-01 21:08:47 +00001// RUN: %clang_cc1 %s -fexceptions -fcxx-exceptions -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck %s
2
3// lifetime.end should be invoked even if the destructor doesn't run due to an
4// exception thrown from previous ctor call.
5
6struct A { A(); ~A(); };
7A Baz(const A&);
8
9void Test1() {
10 // CHECK-LABEL: @_Z5Test1v(
11 // CHECK: getelementptr
Wei Mi65826692016-09-15 06:31:30 +000012 // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP:[^ ]+]])
Tim Shen421119f2016-07-01 21:08:47 +000013 // CHECK-NEXT: getelementptr
Wei Mi65826692016-09-15 06:31:30 +000014 // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP1:[^ ]+]])
Tim Shen421119f2016-07-01 21:08:47 +000015
16 // Normal exit
Wei Mi65826692016-09-15 06:31:30 +000017 // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
18 // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
Tim Shen421119f2016-07-01 21:08:47 +000019
20 // Exception exit
Wei Mi65826692016-09-15 06:31:30 +000021 // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
22 // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
Tim Shen421119f2016-07-01 21:08:47 +000023 Baz(Baz(A()));
24}