]> granicus.if.org Git - clang/commitdiff
Don't add this adjustments for pure virtual member functions.
authorAnders Carlsson <andersca@mac.com>
Sat, 27 Feb 2010 18:16:50 +0000 (18:16 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 27 Feb 2010 18:16:50 +0000 (18:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97334 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp
test/CodeGenCXX/vtable-layout.cpp

index 6fb70d83c2da7c3e342809dce9af0ecec7db4856..8e9e0655e8d2033eceb3488e981cbc2a2087761b 100644 (file)
@@ -1315,8 +1315,12 @@ void VtableBuilder::ComputeThisAdjustments() {
       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;
index 655f6063d9e7d4746bdde9088d1fffffc6283b42..301cd58e988959ef2aaf9875a628b1e427fbfacb 100644 (file)
@@ -753,4 +753,37 @@ struct D : C, B, virtual A {
 };
 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() { }
+
+}