diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-02 15:00:29 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-02 15:00:29 +0000 |
| commit | e791a0546c0dcfe8e5310661b54c431083c3dfa6 (patch) | |
| tree | 3fae7155bed5f4b0b281bc0c914d2adacda33c2c | |
| parent | 07457f0ed9d94b05c2a19ea9631f4cbb57448dad (diff) | |
| download | bcm5719-llvm-e791a0546c0dcfe8e5310661b54c431083c3dfa6.tar.gz bcm5719-llvm-e791a0546c0dcfe8e5310661b54c431083c3dfa6.zip | |
Fix a crash involving pointer-to-data-members of boolean type. We were
constructing an LLVM PointerType directly from the "bool"'s LLVM type
(i1), which resulted in unfortunate pointer type i1*. The fix is to
build the LLVM PointerType from the corresponding Clang PointerType,
so that we get i8* in the case of a bool.
John, please review. I also left a FIXME there because we seem to be
dropping "volatile", which would be rather unfortunate.
llvm-svn: 112819
| -rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 9 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/pointers-to-data-members.cpp | 14 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index a1a53ad5e05..85b52c63220 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -305,8 +305,13 @@ llvm::Value *ItaniumCXXABI::EmitMemberDataPointerAddress(CodeGenFunction &CGF, // Cast the address to the appropriate pointer type, adopting the // address space of the base pointer. - const llvm::Type *PType - = CGF.ConvertType(MPT->getPointeeType())->getPointerTo(AS); + // FIXME: We seem to be losing the "volatile" qualifier on the base pointer. + QualType PtrType = CGF.getContext().getPointerType(MPT->getPointeeType()); + Qualifiers Qs = MPT->getPointeeType().getQualifiers(); + if (AS) + Qs.addAddressSpace(AS); + PtrType = CGF.getContext().getQualifiedType(PtrType, Qs); + const llvm::Type *PType = CGF.ConvertType(PtrType); return Builder.CreateBitCast(Addr, PType); } diff --git a/clang/test/CodeGenCXX/pointers-to-data-members.cpp b/clang/test/CodeGenCXX/pointers-to-data-members.cpp index 60c1661e060..38c7d2815a0 100644 --- a/clang/test/CodeGenCXX/pointers-to-data-members.cpp +++ b/clang/test/CodeGenCXX/pointers-to-data-members.cpp @@ -189,3 +189,17 @@ struct A { A a; } + +namespace BoolPtrToMember { + struct X { + bool member; + }; + + // CHECK: define i8* @_ZN15BoolPtrToMember1fERNS_1XEMS0_b + bool &f(X &x, bool X::*member) { + // CHECK: {{bitcast.* to i8\*}} + // CHECK-NEXT: getelementptr inbounds i8* + // CHECK-NEXT: ret i8* + return x.*member; + } +} |

