diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 18:54:57 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 18:54:57 +0000 |
| commit | 1c698e0d4f9bf3d141c019d33d9040085a8a67dd (patch) | |
| tree | 06a8a21c12749e8da01391132c42bb0ba84b1a25 /lib/CodeGen/CGExpr.cpp | |
| parent | 7db6d838aad4083fe86d7bf703a75fe6e8a17856 (diff) | |
| download | clang-1c698e0d4f9bf3d141c019d33d9040085a8a67dd.tar.gz clang-1c698e0d4f9bf3d141c019d33d9040085a8a67dd.tar.bz2 clang-1c698e0d4f9bf3d141c019d33d9040085a8a67dd.tar.xz | |
More cleanup of data member access and then some.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index b0e091bd0a..ab0f9e9c74 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -993,15 +993,14 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { if (PTy->getPointeeType()->isUnionType()) isUnion = true; CVRQualifiers = PTy->getPointeeType().getCVRQualifiers(); - if (CXXThisExpr *ThisExpr = dyn_cast<CXXThisExpr>(BaseExpr)) { - QualType ClassTy = ThisExpr->getType(); - ClassTy = ClassTy->getPointeeType(); - CXXRecordDecl *ClassDecl = - cast<CXXRecordDecl>(ClassTy->getAsRecordType()->getDecl()); + QualType ClassTy = BaseExpr->getType(); + ClassTy = ClassTy->getPointeeType(); + if (CXXRecordDecl *ClassDecl = + dyn_cast<CXXRecordDecl>(ClassTy->getAsRecordType()->getDecl())) { FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl()); - CXXRecordDecl *BaseClassDecl = - cast<CXXRecordDecl>(Field->getDeclContext()); - BaseValue = AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl); + if (CXXRecordDecl *BaseClassDecl = + dyn_cast<CXXRecordDecl>(Field->getDeclContext())) + BaseValue = AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl); } } else if (isa<ObjCPropertyRefExpr>(BaseExpr) || isa<ObjCKVCRefExpr>(BaseExpr)) { @@ -1021,6 +1020,15 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { if (BaseExpr->getType()->isUnionType()) isUnion = true; CVRQualifiers = BaseExpr->getType().getCVRQualifiers(); + if (CXXRecordDecl *ClassDecl = + dyn_cast<CXXRecordDecl>( + BaseExpr->getType()->getAsRecordType()->getDecl())) { + FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl()); + if (CXXRecordDecl *BaseClassDecl = + dyn_cast<CXXRecordDecl>(Field->getDeclContext())) + BaseValue = + AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl); + } } FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl()); |
