diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-29 00:44:13 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-29 00:44:13 +0000 |
| commit | 82e28742702b50dd67dfebecbef0e7852ca838af (patch) | |
| tree | da1c75b33449b9a03462be1c8f4d688f8d229b12 /clang/lib/CodeGen/CGExprScalar.cpp | |
| parent | be62697e6b72468d4332c296cac32022815bb6c7 (diff) | |
Code refactoring to define getCXXRecordDeclForPointerType
and use it in several places.
llvm-svn: 77411
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 5ded216f03ab..d78082463217 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -442,18 +442,11 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, // The source value may be an integer, or a pointer. 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); - } - } + if (const CXXRecordDecl *ClassDecl = + SrcType->getCXXRecordDeclForPointerType()) + if (const CXXRecordDecl *BaseClassDecl = + DstType->getCXXRecordDeclForPointerType()) + Src = CGF.AddressCXXOfBaseClass(Src, ClassDecl, BaseClassDecl); return Builder.CreateBitCast(Src, DstTy, "conv"); } assert(SrcType->isIntegerType() && "Not ptr->ptr or int->ptr conversion?"); |
