Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / eh-aggregate-copy-destroy.cpp
blob37d5b8654eee0a710c671249e4016f06d2a2fa7d
1 // Check that in case of copying an array of memcpy-able objects, their
2 // destructors will be called if an exception is thrown.
3 //
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -std=c++98 -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
5 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -std=c++11 -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
7 struct ImplicitCopy {
8 int x;
9 ImplicitCopy() { x = 10; }
10 ~ImplicitCopy() { x = 20; }
13 struct ThrowCopy {
14 ThrowCopy() {}
15 ThrowCopy(const ThrowCopy &) { throw 1; }
18 struct Container {
19 ImplicitCopy b[2];
20 ThrowCopy c;
23 int main () {
24 try {
25 Container c1;
26 // CHECK-LABEL: main
27 // CHECK-NOT: call void @_ZN9ThrowCopyC1ERKS_
28 // CHECK: invoke void @_ZN9ThrowCopyC1ERKS_
29 // CHECK98: invoke void @_ZN12ImplicitCopyD1Ev
30 // CHECK11: call void @_ZN12ImplicitCopyD1Ev
31 Container c2(c1);
33 catch (...) {
34 return 1;
37 return 0;