diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-01-26 19:30:26 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-01-26 19:30:26 +0000 |
| commit | 929025d1a614bef2ef68a50898cccfb283d3abf3 (patch) | |
| tree | 758e87b50d534c9056b623580b78ade5983335b6 /clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp | |
| parent | 59066a0803e7cc10ba004cf862baf19a4ad161ca (diff) | |
| download | bcm5719-llvm-929025d1a614bef2ef68a50898cccfb283d3abf3.tar.gz bcm5719-llvm-929025d1a614bef2ef68a50898cccfb283d3abf3.zip | |
[MS ABI] Allow a member pointers' converted type to change
Member pointers in the MS ABI are tricky for a variety of reasons.
The size of a member pointer is indeterminate until the program reaches
a point where the representation is required to be known. However,
*pointers* to member pointers may exist without knowing the pointee
type's representation. In these cases, we synthesize an opaque LLVM
type for the pointee type.
However, we can be in a situation where the underlying member pointer's
representation became known mid-way through the program. To account for
this, we attempted to manicure CodeGen's type-cache so that we can
replace the opaque member pointer type with the real deal while leaving
the pointer types unperturbed. This, unfortunately, is a problematic
approach to take as we will violate CodeGen's invariants.
These violations are mostly harmless but let's do the right thing
instead: invalidate the type-cache if a member pointer's LLVM
representation changes.
This fixes PR26313.
llvm-svn: 258839
Diffstat (limited to 'clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp')
| -rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp index fd22c003420..a3985ba09c0 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -3,16 +3,29 @@ // RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -fms-extensions -verify // RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -DMEMFUN -fms-extensions -verify +struct PR26313_Y; +typedef void (PR26313_Y::*PR26313_FUNC)(); +struct PR26313_X { + PR26313_FUNC *ptr; + PR26313_X(); +}; +PR26313_X::PR26313_X() {} +void PR26313_f(PR26313_FUNC *p) { delete p; } + +struct PR26313_Z; +int PR26313_Z::**a = nullptr; +int PR26313_Z::*b = *a; +// CHECK-DAG: @"\01?a@@3PAPQPR26313_Z@@HA" = global %0* null, align 4 +// CHECK-DAG: @"\01?b@@3PQPR26313_Z@@HQ1@" = global { i32, i32, i32 } { i32 0, i32 0, i32 -1 }, align 4 + namespace PR20947 { struct A; int A::**a = nullptr; -// CHECK: %[[opaque0:.*]] = type opaque -// CHECK: %[[opaque1:.*]] = type opaque -// CHECK: @"\01?a@PR20947@@3PAPQA@1@HA" = global %[[opaque0]]* null, align 4 +// CHECK-DAG: @"\01?a@PR20947@@3PAPQA@1@HA" = global %{{.*}}* null, align 4 struct B; int B::*&b = b; -// CHECK: @"\01?b@PR20947@@3AAPQB@1@HA" = global %[[opaque1]]* null, align 4 +// CHECK-DAG: @"\01?b@PR20947@@3AAPQB@1@HA" = global %{{.*}}* null, align 4 } namespace PR20017 { |

