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/CGExpr.cpp | |
| parent | be62697e6b72468d4332c296cac32022815bb6c7 (diff) | |
Code refactoring to define getCXXRecordDeclForPointerType
and use it in several places.
llvm-svn: 77411
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 3a37f2d62838..39ef799cd3e1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -993,12 +993,10 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { if (PTy->getPointeeType()->isUnionType()) isUnion = true; CVRQualifiers = PTy->getPointeeType().getCVRQualifiers(); - QualType ClassTy = BaseExpr->getType(); - ClassTy = ClassTy->getPointeeType(); - if (CXXRecordDecl *ClassDecl = - dyn_cast<CXXRecordDecl>(ClassTy->getAsRecordType()->getDecl())) { + if (const CXXRecordDecl *ClassDecl = + BaseExpr->getType()->getCXXRecordDeclForPointerType()) { FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl()); - if (CXXRecordDecl *BaseClassDecl = + if (const CXXRecordDecl *BaseClassDecl = dyn_cast<CXXRecordDecl>(Field->getDeclContext())) BaseValue = AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl); } @@ -1017,14 +1015,15 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { isNonGC = true; // FIXME: this isn't right for bitfields. BaseValue = BaseLV.getAddress(); - if (BaseExpr->getType()->isUnionType()) + QualType BaseTy = BaseExpr->getType(); + if (BaseTy->isUnionType()) isUnion = true; - CVRQualifiers = BaseExpr->getType().getCVRQualifiers(); - if (CXXRecordDecl *ClassDecl = + CVRQualifiers = BaseTy.getCVRQualifiers(); + if (const CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>( - BaseExpr->getType()->getAsRecordType()->getDecl())) { + BaseTy->getAsRecordType()->getDecl())) { FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl()); - if (CXXRecordDecl *BaseClassDecl = + if (const CXXRecordDecl *BaseClassDecl = dyn_cast<CXXRecordDecl>(Field->getDeclContext())) BaseValue = AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl); |
