diff options
author | John McCall <rjmccall@apple.com> | 2012-03-21 06:57:19 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-03-21 06:57:19 +0000 |
commit | 260a3e4370a15bc3da9d2d9461b6f179c68dd348 (patch) | |
tree | da5fb2598d2ed3a5f09761ee962cb502900a7a4b /test/CodeGenCXX/vtable-layout.cpp | |
parent | 247c7196526110ced1c08ebda1079201b6108d78 (diff) |
For the annals of subtle but terrible bugs: fix a longstanding bug
in vtable layout where virtual methods inherited from virtual bases
could be assigned the same vcall adjustment slot if they shared
a name and parameter signature but differed in their
cv-qualification. The code was already trying to handle this
case, but unfortunately used the ordinary type qualifiers
(which are always empty here) instead of the method qualifiers.
This seems like something that the API should discourage, but
I don't know how to carry that principle out in this instance.
Eliminate this function's need for an ASTContext while we're at it.
This bug affects the ABI, and fixing it brings us into accord with
the Itanium ABI (and GCC's implementation of it), but, obviously,
technically breaks full compatibility with previous releases of Clang.
Just letting you know.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r-- | test/CodeGenCXX/vtable-layout.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp index bd696813c8..d7644b98ae 100644 --- a/test/CodeGenCXX/vtable-layout.cpp +++ b/test/CodeGenCXX/vtable-layout.cpp @@ -42,6 +42,7 @@ // RUN: FileCheck --check-prefix=CHECK-41 %s < %t // RUN: FileCheck --check-prefix=CHECK-42 %s < %t // RUN: FileCheck --check-prefix=CHECK-43 %s < %t +// RUN: FileCheck --check-prefix=CHECK-44 %s < %t // For now, just verify this doesn't crash. namespace test0 { @@ -1701,3 +1702,28 @@ struct C : B { C* C::f() { return 0; } } + +// rdar://problem/10959710 +namespace Test38 { + struct A { + virtual void *foo(); + virtual const void *foo() const; + }; + + // CHECK-44: Vtable for 'Test38::B' (7 entries). + // CHECK-44-NEXT: 0 | vbase_offset (0) + // CHECK-44-NEXT: 1 | vcall_offset (0) + // CHECK-44-NEXT: 2 | vcall_offset (0) + // CHECK-44-NEXT: 3 | offset_to_top (0) + // CHECK-44-NEXT: 4 | Test38::B RTTI + // CHECK-44-NEXT: -- (Test38::A, 0) vtable address -- + // CHECK-44-NEXT: -- (Test38::B, 0) vtable address -- + // CHECK-44-NEXT: 5 | void *Test38::B::foo() + // CHECK-44-NEXT: 6 | const void *Test38::B::foo() const + class B : virtual public A { + void *foo(); + const void *foo() const; + }; + + void *B::foo() { return 0; } +} |