[cfe-commits] r81587 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/vtable-cast-crash.cpp

Anders Carlsson andersca at mac.com
Fri Sep 11 17:00:29 PDT 2009


Author: andersca
Date: Fri Sep 11 19:00:29 2009
New Revision: 81587

URL: http://llvm.org/viewvc/llvm-project?rev=81587&view=rev
Log:
Fix a crash when generating vtables that contain destructors.

Added:
    cfe/trunk/test/CodeGenCXX/vtable-cast-crash.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=81587&r1=81586&r2=81587&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Sep 11 19:00:29 2009
@@ -993,20 +993,19 @@
            ++mi)
         if (mi->isVirtual()) {
           const CXXMethodDecl *MD = *mi;
-          llvm::Constant *m = wrap(CGM.GetAddrOfFunction(MD, Ptr8Ty));
+          llvm::Constant *m = wrap(CGM.GetAddrOfFunction(MD));
           OverrideMethod(MD, m, MorallyVirtual, Offset);
         }
     }
   }
 
   void AddMethod(const CXXMethodDecl *MD, bool MorallyVirtual, Index_t Offset) {
-    GlobalDecl GD;
+    llvm::Constant *m = 0;
     if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(MD))
-      GD = GlobalDecl(Dtor, Dtor_Complete);
+      m = wrap(CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete));
     else
-      GD = GlobalDecl(MD);
+      m = wrap(CGM.GetAddrOfFunction(MD));
 
-    llvm::Constant *m = wrap(CGM.GetAddrOfFunction(GD, Ptr8Ty));
     // If we can find a previously allocated slot for this, reuse it.
     if (OverrideMethod(MD, m, MorallyVirtual, Offset))
       return;

Added: cfe/trunk/test/CodeGenCXX/vtable-cast-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-cast-crash.cpp?rev=81587&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-cast-crash.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/vtable-cast-crash.cpp Fri Sep 11 19:00:29 2009
@@ -0,0 +1,21 @@
+// RUN: clang-cc -emit-llvm-only %s
+struct A
+{
+A();    
+virtual ~A();
+};
+
+struct B: A
+{
+  B();
+  ~B();
+};
+
+B::B()
+{
+}
+
+B::~B()
+{
+}
+                         





More information about the cfe-commits mailing list