From 1a50477385095bcbff8f62b53314c75a5a411122 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 1 Sep 2009 17:02:21 +0000 Subject: [PATCH] Fixed a property getter ir-gen crash. llvm-svn: 80681 --- clang/lib/CodeGen/CGExpr.cpp | 5 +++-- clang/lib/CodeGen/CGObjC.cpp | 1 + clang/test/CodeGenObjC/property-agrr-getter.m | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 48326ee832ef..43120156f8a6 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1026,8 +1026,9 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { if (PTy->getPointeeType()->isUnionType()) isUnion = true; CVRQualifiers = PTy->getPointeeType().getCVRQualifiers(); - } else if (isa(BaseExpr) || - isa(BaseExpr)) { + } else if (isa(BaseExpr->IgnoreParens()) || + isa( + BaseExpr->IgnoreParens())) { RValue RV = EmitObjCPropertyGet(BaseExpr); BaseValue = RV.getAggregateAddr(); if (BaseExpr->getType()->isUnionType()) diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 8c0c225d1ac6..58999129813b 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -327,6 +327,7 @@ RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp, } RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { + Exp = Exp->IgnoreParens(); // FIXME: Split it into two separate routines. if (const ObjCPropertyRefExpr *E = dyn_cast(Exp)) { Selector S = E->getProperty()->getGetterName(); diff --git a/clang/test/CodeGenObjC/property-agrr-getter.m b/clang/test/CodeGenObjC/property-agrr-getter.m index 0e9b040b1b98..46205796936f 100644 --- a/clang/test/CodeGenObjC/property-agrr-getter.m +++ b/clang/test/CodeGenObjC/property-agrr-getter.m @@ -15,3 +15,24 @@ typedef struct { } @end + +typedef struct _NSSize { + float width; + float height; +} NSSize; + + +@interface AnObject +{ + NSSize size; +} + +@property NSSize size; + +@end + +float f () +{ + AnObject* obj; + return (obj.size).width; +}