]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/temporary-lifetime-exceptions.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / CodeGen / temporary-lifetime-exceptions.cpp
1 // 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
6 struct A { A(); ~A(); };
7 A Baz(const A&);
8
9 void Test1() {
10   // CHECK-LABEL: @_Z5Test1v(
11   // CHECK: getelementptr
12   // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP:[^ ]+]])
13   // CHECK-NEXT: getelementptr
14   // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP1:[^ ]+]])
15
16   // Normal exit
17   // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
18   // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
19
20   // Exception exit
21   // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
22   // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
23   Baz(Baz(A()));
24 }