Author: andersca
Date: Sat Feb 27 12:16:50 2010
New Revision: 97334

URL: http://llvm.org/viewvc/llvm-project?rev=97334&view=rev
Log:
Don't add this adjustments for pure virtual member functions.

Modified:
    cfe/trunk/lib/CodeGen/CGVtable.cpp
    cfe/trunk/test/CodeGenCXX/vtable-layout.cpp

Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=97334&r1=97333&r2=97334&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Feb 27 12:16:50 2010
@@ -1315,8 +1315,12 @@
       continue;
     
     uint64_t VtableIndex = MethodInfo.VtableIndex;
-    
-    // Ignore this adjustments for unused function pointers.
+
+    // Ignore adjustments for pure virtual member functions.
+    if (Overrider.Method->isPure())
+      continue;
+
+    // Ignore adjustments for unused function pointers.
     if (Components[VtableIndex].getKind() == 
         VtableComponent::CK_UnusedFunctionPointer)
       continue;

Modified: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-layout.cpp?rev=97334&r1=97333&r2=97334&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp Sat Feb 27 12:16:50 2010
@@ -753,4 +753,37 @@
 };
 void D::f() { }
 
-}
\ No newline at end of file
+}
+
+namespace Test20 {
+
+// pure virtual member functions should never have 'this' adjustments.
+
+struct A {
+  virtual void f() = 0;
+  virtual void g();
+};
+
+struct B : A { };
+
+// CHECK:      Vtable for 'Test20::C' (9 entries).
+// CHECK-NEXT:    0 | offset_to_top (0)
+// CHECK-NEXT:    1 | Test20::C RTTI
+// CHECK-NEXT:        -- (Test20::A, 0) vtable address --
+// CHECK-NEXT:        -- (Test20::C, 0) vtable address --
+// CHECK-NEXT:    2 | void Test20::C::f() [pure]
+// CHECK-NEXT:    3 | void Test20::A::g()
+// CHECK-NEXT:    4 | void Test20::C::h()
+// CHECK-NEXT:    5 | offset_to_top (-8)
+// CHECK-NEXT:    6 | Test20::C RTTI
+// CHECK-NEXT:        -- (Test20::A, 8) vtable address --
+// CHECK-NEXT:        -- (Test20::B, 8) vtable address --
+// CHECK-NEXT:    7 | void Test20::C::f() [pure]
+// CHECK-NEXT:    8 | void Test20::A::g()
+struct C : A, B { 
+  virtual void f() = 0;
+  virtual void h();
+};
+void C::h() { }
+
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to