summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/nrvo.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-17 15:52:46 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-17 15:52:46 +0000
commit9154b5dffe4ffa014c65f4629a8429c4b166e3b3 (patch)
treecc0771b6ec00b1cbd43cd1bfa89a434f0dbf89b6 /clang/test/CodeGenCXX/nrvo.cpp
parentf5e8c86424333a7ccbf71c2b25ef3b85749bf358 (diff)
downloadbcm5719-llvm-9154b5dffe4ffa014c65f4629a8429c4b166e3b3.tar.gz
bcm5719-llvm-9154b5dffe4ffa014c65f4629a8429c4b166e3b3.zip
Ensure that destructors are called for NRVO'd objects when the
function does not return. Thanks to Eli for pointing out this corner case. llvm-svn: 103941
Diffstat (limited to 'clang/test/CodeGenCXX/nrvo.cpp')
-rw-r--r--clang/test/CodeGenCXX/nrvo.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/nrvo.cpp b/clang/test/CodeGenCXX/nrvo.cpp
index 195b2b81fa0..9ee553673f1 100644
--- a/clang/test/CodeGenCXX/nrvo.cpp
+++ b/clang/test/CodeGenCXX/nrvo.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O1 -o - %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s | FileCheck --check-prefix=CHECK-EH %s
// Test code generation for the named return value optimization.
@@ -15,9 +15,12 @@ X test0() {
X x;
// CHECK-NOT: call void @_ZN1XD1Ev
// CHECK: ret void
+ // CHECK-EH: br label
+ // CHECK-EH: call void @_ZN1XD1Ev
+ // CHECK-EH: br label
+ // CHECK-EH: invoke void @_ZN1XD1Ev
// CHECK-EH: ret void
return x;
- // CHECK-EH: invoke void @_ZN1XD1Ev
}
// CHECK: define void @_Z5test1b(
@@ -63,3 +66,19 @@ X test3(bool B) {
X x;
return x;
}
+
+extern "C" void exit(int) throw();
+
+// CHECK: define void @_Z5test4b
+X test4(bool B) {
+ {
+ // CHECK: tail call void @_ZN1XC1Ev
+ X x;
+ // CHECK: br i1
+ if (B)
+ return x;
+ }
+ // CHECK: tail call void @_ZN1XD1Ev
+ // CHECK: tail call void @exit(i32 1)
+ exit(1);
+}
OpenPOWER on IntegriCloud