diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 22:00:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 22:00:58 +0000 |
commit | fa9f8b4cf962d865c4b430a25aca2fb5faa84337 (patch) | |
tree | d0f97b290be53f1ac014356735fe074e8c9a37f0 /lib/CodeGen/CGExprScalar.cpp | |
parent | 4a28932dba03132dabbe70abdadcaae468dd7933 (diff) |
ir-gen derived-to-base conversion in implicit casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77374 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index cbca7aa6d2..5ded216f03 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -440,8 +440,22 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, // pointer type. if (isa<llvm::PointerType>(DstTy)) { // The source value may be an integer, or a pointer. - if (isa<llvm::PointerType>(Src->getType())) + if (isa<llvm::PointerType>(Src->getType())) { + // Some heavy lifting for derived to base conversion. + if (const PointerType *PT = SrcType->getAsPointerType()) { + QualType SrcClassTy = PT->getPointeeType(); + if (const RecordType *RT = SrcClassTy->getAsRecordType()) + if (CXXRecordDecl *ClassDecl = + dyn_cast<CXXRecordDecl>(RT->getDecl())) { + QualType DstClassType = DstType->getPointeeType(); + if (const RecordType *DRT = DstClassType->getAsRecordType()) + if (CXXRecordDecl *BaseClassDecl = + dyn_cast<CXXRecordDecl>(DRT->getDecl())) + Src = CGF.AddressCXXOfBaseClass(Src, ClassDecl, BaseClassDecl); + } + } return Builder.CreateBitCast(Src, DstTy, "conv"); + } assert(SrcType->isIntegerType() && "Not ptr->ptr or int->ptr conversion?"); // First, convert to the correct width so that we control the kind of // extension. |