diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-10-25 14:32:25 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-10-25 14:32:25 +0000 |
commit | 9a8f13961cc6fc9471ff9c916c7576c0bc13de39 (patch) | |
tree | 05e45eb81660bf306a4b068e96d69c5dff21de5c /clang/lib/Sema/SemaExprObjC.cpp | |
parent | 6ca458e49a3addfa7436a0c02e2a84c4a174f13a (diff) | |
download | bcm5719-llvm-9a8f13961cc6fc9471ff9c916c7576c0bc13de39.tar.gz bcm5719-llvm-9a8f13961cc6fc9471ff9c916c7576c0bc13de39.zip |
Revert r142914 and r142915, due to possibly missing file.
r142914: "Introduce a placeholder type for "pseudo object""
r142915: "Pull the pseudo-object stuff into its own file."
llvm-svn: 142921
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index ceff1de3d49..527983805c9 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -527,35 +527,6 @@ ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel, return Method; } -/// LookupMethodInType - Look up a method in an ObjCObjectType. -ObjCMethodDecl *Sema::LookupMethodInObjectType(Selector sel, QualType type, - bool isInstance) { - const ObjCObjectType *objType = type->castAs<ObjCObjectType>(); - if (ObjCInterfaceDecl *iface = objType->getInterface()) { - // Look it up in the main interface (and categories, etc.) - if (ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance)) - return method; - - // Okay, look for "private" methods declared in any - // @implementations we've seen. - if (isInstance) { - if (ObjCMethodDecl *method = LookupPrivateInstanceMethod(sel, iface)) - return method; - } else { - if (ObjCMethodDecl *method = LookupPrivateClassMethod(sel, iface)) - return method; - } - } - - // Check qualifiers. - for (ObjCObjectType::qual_iterator - i = objType->qual_begin(), e = objType->qual_end(); i != e; ++i) - if (ObjCMethodDecl *method = (*i)->lookupMethod(sel, isInstance)) - return method; - - return 0; -} - /// LookupMethodInQualifiedType - Lookups up a method in protocol qualifier /// list of a qualified objective pointer type. ObjCMethodDecl *Sema::LookupMethodInQualifiedType(Selector Sel, @@ -604,14 +575,23 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, // Check whether we can reference this property. if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); + QualType ResTy = PD->getType(); + ResTy = ResTy.getNonLValueExprType(Context); + Selector Sel = PP.getSelectorTable().getNullarySelector(Member); + ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel); + if (Getter && + (Getter->hasRelatedResultType() + || DiagnosePropertyAccessorMismatch(PD, Getter, MemberLoc))) + ResTy = getMessageSendResultType(QualType(OPT, 0), Getter, false, + Super); if (Super) - return Owned(new (Context) ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, + return Owned(new (Context) ObjCPropertyRefExpr(PD, ResTy, VK_LValue, OK_ObjCProperty, MemberLoc, SuperLoc, SuperType)); else - return Owned(new (Context) ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, + return Owned(new (Context) ObjCPropertyRefExpr(PD, ResTy, VK_LValue, OK_ObjCProperty, MemberLoc, BaseExpr)); } @@ -623,16 +603,17 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); + QualType T = PD->getType(); + if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl()) + T = getMessageSendResultType(QualType(OPT, 0), Getter, false, Super); if (Super) - return Owned(new (Context) ObjCPropertyRefExpr(PD, - Context.PseudoObjectTy, + return Owned(new (Context) ObjCPropertyRefExpr(PD, T, VK_LValue, OK_ObjCProperty, MemberLoc, SuperLoc, SuperType)); else - return Owned(new (Context) ObjCPropertyRefExpr(PD, - Context.PseudoObjectTy, + return Owned(new (Context) ObjCPropertyRefExpr(PD, T, VK_LValue, OK_ObjCProperty, MemberLoc, @@ -687,16 +668,28 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, return ExprError(); if (Getter || Setter) { + QualType PType; + if (Getter) + PType = getMessageSendResultType(QualType(OPT, 0), Getter, false, Super); + else { + ParmVarDecl *ArgDecl = *Setter->param_begin(); + PType = ArgDecl->getType().getUnqualifiedType(); // can't be an array + } + + ExprValueKind VK = VK_LValue; + ExprObjectKind OK = OK_ObjCProperty; + if (!getLangOptions().CPlusPlus && !PType.hasQualifiers() && + PType->isVoidType()) + VK = VK_RValue, OK = OK_Ordinary; + if (Super) return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, + PType, VK, OK, MemberLoc, SuperLoc, SuperType)); else return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, + PType, VK, OK, MemberLoc, BaseExpr)); } @@ -832,17 +825,34 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, return ExprError(); if (Getter || Setter) { + QualType PType; + + ExprValueKind VK = VK_LValue; + if (Getter) { + PType = getMessageSendResultType(Context.getObjCInterfaceType(IFace), + Getter, true, + receiverNamePtr->isStr("super")); + if (!getLangOptions().CPlusPlus && + !PType.hasQualifiers() && PType->isVoidType()) + VK = VK_RValue; + } else { + for (ObjCMethodDecl::param_iterator PI = Setter->param_begin(), + E = Setter->param_end(); PI != E; ++PI) + PType = (*PI)->getType(); + VK = VK_LValue; + } + + ExprObjectKind OK = (VK == VK_RValue ? OK_Ordinary : OK_ObjCProperty); + if (IsSuper) return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, + PType, VK, OK, propertyNameLoc, receiverNameLoc, Context.getObjCInterfaceType(IFace))); return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, + PType, VK, OK, propertyNameLoc, receiverNameLoc, IFace)); } |