]> granicus.if.org Git - clang/commitdiff
[pr22293] Don't crash during codegen of a recursive destructor.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 23 Jan 2015 05:26:38 +0000 (05:26 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 23 Jan 2015 05:26:38 +0000 (05:26 +0000)
In ItaniumCXXABI::EmitCXXDestructors we first emit the base destructor
and then try to emit the complete one as an alias.

If in the base ends up calling the complete destructor, the GD for the
complete will be in the list of deferred decl by the time we replace
it with an alias and delete the original GV.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226896 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.h
test/CodeGenCXX/ctor-dtor-alias.cpp

index 4559aecff1233a4b0190196b7a0f235c21a772ad..81b758a7396a98aa48cc928485c605e6d23e0812 100644 (file)
@@ -324,7 +324,7 @@ private:
   /// referenced. These get code generated when the module is done.
   struct DeferredGlobal {
     DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {}
-    llvm::AssertingVH<llvm::GlobalValue> GV;
+    llvm::TrackingVH<llvm::GlobalValue> GV;
     GlobalDecl GD;
   };
   std::vector<DeferredGlobal> DeferredDeclsToEmit;
index 6f8aedc0712cec2a6b5d486601b1d0a242e70c87..4c119718afbd09f2a0b2bc2ac0597f2b8abec2d1 100644 (file)
@@ -235,3 +235,14 @@ foo::~foo() {}
 // CHECK6: @_ZN6test113fooD2Ev = alias {{.*}} @_ZN6test113barD2Ev
 // CHECK6: @_ZN6test113fooD1Ev = alias {{.*}} @_ZN6test113fooD2Ev
 }
+
+namespace test12 {
+template <int>
+struct foo {
+  ~foo() { delete this; }
+};
+
+template class foo<1>;
+// CHECK6: @_ZN6test123fooILi1EED1Ev = weak_odr alias {{.*}} @_ZN6test123fooILi1EED2Ev
+// CHECK6: define weak_odr void @_ZN6test123fooILi1EED2Ev({{.*}}) {{.*}} comdat($_ZN6test123fooILi1EED5Ev)
+}