[cfe-commits] r150924 - /cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Sun Feb 19 04:27:51 PST 2012


Author: cornedbee
Date: Sun Feb 19 06:27:51 2012
New Revision: 150924

URL: http://llvm.org/viewvc/llvm-project?rev=150924&view=rev
Log:
Add a testcase to show that temporaries from the initializer list are destroyed correctly.

Modified:
    cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=150924&r1=150923&r2=150924&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp Sun Feb 19 06:27:51 2012
@@ -58,12 +58,17 @@
 struct destroyme2 {
   ~destroyme2();
 };
+struct witharg1 {
+  witharg1(const destroyme1&);
+  ~witharg1();
+};
 
 
 void fn2() {
   // CHECK: define void @_Z3fn2v
   void target(std::initializer_list<destroyme1>);
   // objects should be destroyed before dm2, after call returns
+  // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E
   target({ destroyme1(), destroyme1() });
   // CHECK: call void @_ZN10destroyme1D1Ev
   destroyme2 dm2;
@@ -78,3 +83,28 @@
   // CHECK: call void @_ZN10destroyme2D1Ev
   // CHECK: call void @_ZN10destroyme1D1Ev
 }
+
+void fn4() {
+  // CHECK: define void @_Z3fn4v
+  void target(std::initializer_list<witharg1>);
+  // objects should be destroyed before dm2, after call returns
+  // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+  // CHECK: call void @_Z6targetSt16initializer_listI8witharg1E
+  target({ witharg1(destroyme1()), witharg1(destroyme1()) });
+  // CHECK: call void @_ZN8witharg1D1Ev
+  // CHECK: call void @_ZN10destroyme1D1Ev
+  destroyme2 dm2;
+  // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn5() {
+  // CHECK: define void @_Z3fn5v
+  // temps should be destroyed before dm2
+  // objects should be destroyed after dm2
+  // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+  auto list = { witharg1(destroyme1()), witharg1(destroyme1()) };
+  // CHECK: call void @_ZN10destroyme1D1Ev
+  destroyme2 dm2;
+  // CHECK: call void @_ZN10destroyme2D1Ev
+  // CHECK: call void @_ZN8witharg1D1Ev
+}





More information about the cfe-commits mailing list