diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Expr.cpp | 40 | ||||
-rw-r--r-- | lib/AST/ExprClassification.cpp | 18 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 1 | ||||
-rw-r--r-- | lib/AST/StmtDumper.cpp | 34 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 18 | ||||
-rw-r--r-- | lib/AST/StmtProfile.cpp | 19 | ||||
-rw-r--r-- | lib/Checker/CheckObjCDealloc.cpp | 4 | ||||
-rw-r--r-- | lib/Checker/GRExprEngine.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 25 | ||||
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 118 | ||||
-rw-r--r-- | lib/CodeGen/CGValue.h | 12 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 5 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 1 | ||||
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 82 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 56 | ||||
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 19 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 99 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 50 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterStmt.cpp | 40 |
24 files changed, 248 insertions, 435 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 6e56603c53..265788a081 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1338,21 +1338,11 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, return false; } - case ObjCImplicitSetterGetterRefExprClass: { // Dot syntax for message send. -#if 0 - const ObjCImplicitSetterGetterRefExpr *Ref = - cast<ObjCImplicitSetterGetterRefExpr>(this); - // FIXME: We really want the location of the '.' here. - Loc = Ref->getLocation(); - R1 = SourceRange(Ref->getLocation(), Ref->getLocation()); - if (Ref->getBase()) - R2 = Ref->getBase()->getSourceRange(); -#else + case ObjCPropertyRefExprClass: Loc = getExprLoc(); R1 = getSourceRange(); -#endif return true; - } + case StmtExprClass: { // Statement exprs don't logically have side effects themselves, but are // sometimes used in macros in ways that give them a type that is unused. @@ -1635,7 +1625,6 @@ Expr::CanThrowResult Expr::CanThrow(ASTContext &C) const { // specs. case ObjCMessageExprClass: case ObjCPropertyRefExprClass: - case ObjCImplicitSetterGetterRefExprClass: return CT_Can; // Many other things have subexpressions, so we have to test those. @@ -1838,8 +1827,7 @@ bool Expr::isTemporaryObject(ASTContext &C, const CXXRecordDecl *TempTy) const { // Temporaries are by definition pr-values of class type. if (!E->Classify(C).isPRValue()) { // In this context, property reference is a message call and is pr-value. - if (!isa<ObjCPropertyRefExpr>(E) && - !isa<ObjCImplicitSetterGetterRefExpr>(E)) + if (!isa<ObjCPropertyRefExpr>(E)) return false; } @@ -2537,33 +2525,19 @@ Stmt::child_iterator ObjCIvarRefExpr::child_end() { return &Base+1; } // ObjCPropertyRefExpr Stmt::child_iterator ObjCPropertyRefExpr::child_begin() { - if (BaseExprOrSuperType.is<Stmt*>()) { + if (Receiver.is<Stmt*>()) { // Hack alert! - return reinterpret_cast<Stmt**> (&BaseExprOrSuperType); + return reinterpret_cast<Stmt**> (&Receiver); } return child_iterator(); } Stmt::child_iterator ObjCPropertyRefExpr::child_end() -{ return BaseExprOrSuperType.is<Stmt*>() ? - reinterpret_cast<Stmt**> (&BaseExprOrSuperType)+1 : +{ return Receiver.is<Stmt*>() ? + reinterpret_cast<Stmt**> (&Receiver)+1 : child_iterator(); } -// ObjCImplicitSetterGetterRefExpr -Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_begin() { - // If this is accessing a class member or super, skip that entry. - // Technically, 2nd condition is sufficient. But I want to be verbose - if (isSuperReceiver() || !Base) - return child_iterator(); - return &Base; -} -Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_end() { - if (isSuperReceiver() || !Base) - return child_iterator(); - return &Base+1; -} - // ObjCIsaExpr Stmt::child_iterator ObjCIsaExpr::child_begin() { return &Base; } Stmt::child_iterator ObjCIsaExpr::child_end() { return &Base+1; } diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 4025f18a3b..e55545e693 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -104,7 +104,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::PredefinedExprClass: // Property references are lvalues case Expr::ObjCPropertyRefExprClass: - case Expr::ObjCImplicitSetterGetterRefExprClass: // C++ [expr.typeid]p1: The result of a typeid expression is an lvalue of... case Expr::CXXTypeidExprClass: // Unresolved lookups get classified as lvalues. @@ -195,8 +194,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { Cl::Kinds K = ClassifyInternal(Ctx, Op); if (K != Cl::CL_LValue) return K; - if (isa<ObjCPropertyRefExpr>(Op) || - isa<ObjCImplicitSetterGetterRefExpr>(Op)) + if (isa<ObjCPropertyRefExpr>(Op)) return Cl::CL_SubObjCPropertySetting; return Cl::CL_LValue; } @@ -368,8 +366,7 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) { return Cl::CL_LValue; // ObjC property accesses are not lvalues, but get special treatment. Expr *Base = E->getBase()->IgnoreParens(); - if (isa<ObjCPropertyRefExpr>(Base) || - isa<ObjCImplicitSetterGetterRefExpr>(Base)) + if (isa<ObjCPropertyRefExpr>(Base)) return Cl::CL_SubObjCPropertySetting; return ClassifyInternal(Ctx, Base); } @@ -395,8 +392,7 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) { if (E->isArrow()) return Cl::CL_LValue; Expr *Base = E->getBase()->IgnoreParenImpCasts(); - if (isa<ObjCPropertyRefExpr>(Base) || - isa<ObjCImplicitSetterGetterRefExpr>(Base)) + if (isa<ObjCPropertyRefExpr>(Base)) return Cl::CL_SubObjCPropertySetting; return ClassifyInternal(Ctx, E->getBase()); } @@ -498,9 +494,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E, // Assignment to a property in ObjC is an implicit setter access. But a // setter might not exist. - if (const ObjCImplicitSetterGetterRefExpr *Expr = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(E)) { - if (Expr->getSetterMethod() == 0) + if (const ObjCPropertyRefExpr *Expr = dyn_cast<ObjCPropertyRefExpr>(E)) { + if (Expr->isImplicitProperty() && Expr->getImplicitPropertySetter() == 0) return Cl::CM_NoSetterProperty; } @@ -517,8 +512,7 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E, // Records with any const fields (recursively) are not modifiable. if (const RecordType *R = CT->getAs<RecordType>()) { - assert((isa<ObjCImplicitSetterGetterRefExpr>(E) || - isa<ObjCPropertyRefExpr>(E) || + assert((isa<ObjCPropertyRefExpr>(E) || !Ctx.getLangOptions().CPlusPlus) && "C++ struct assignment should be resolved by the " "copy assignment operator."); diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index f4685933dc..019cfc9b80 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2506,7 +2506,6 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case Expr::ObjCProtocolExprClass: case Expr::ObjCIvarRefExprClass: case Expr::ObjCPropertyRefExprClass: - case Expr::ObjCImplicitSetterGetterRefExprClass: case Expr::ObjCIsaExprClass: case Expr::ShuffleVectorExprClass: case Expr::BlockExprClass: diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index 15a8d61c88..6f9a2d574b 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -172,8 +172,6 @@ namespace { void VisitObjCSelectorExpr(ObjCSelectorExpr *Node); void VisitObjCProtocolExpr(ObjCProtocolExpr *Node); void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node); - void VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *Node); void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node); }; } @@ -607,27 +605,19 @@ void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) { void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { DumpExpr(Node); - if (Node->isSuperReceiver()) - OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"' - << " super"; - else - OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"'; -} - -void StmtDumper::VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *Node) { - DumpExpr(Node); + if (Node->isImplicitProperty()) { + OS << " Kind=MethodRef Getter=\"" + << Node->getImplicitPropertyGetter()->getSelector().getAsString() + << "\" Setter=\""; + if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter()) + OS << Setter->getSelector().getAsString(); + else + OS << "(null)"; + OS << "\""; + } else { + OS << " Kind=PropertyRef Property=\"" << Node->getExplicitProperty() << '"'; + } - ObjCMethodDecl *Getter = Node->getGetterMethod(); - ObjCMethodDecl *Setter = Node->getSetterMethod(); - OS << " Kind=MethodRef Getter=\"" - << Getter->getSelector().getAsString() - << "\" Setter=\""; - if (Setter) - OS << Setter->getSelector().getAsString(); - else - OS << "(null)"; - OS << "\""; if (Node->isSuperReceiver()) OS << " super"; } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index d4791bcd0e..9dfde62deb 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -516,20 +516,10 @@ void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { OS << "."; } - OS << Node->getProperty()->getName(); -} - -void StmtPrinter::VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *Node) { - if (Node->isSuperReceiver()) - OS << "super."; - else if (Node->getBase()) { - PrintExpr(Node->getBase()); - OS << "."; - } - if (Node->getGetterMethod()) - OS << Node->getGetterMethod(); - + if (Node->isImplicitProperty()) + OS << Node->getImplicitPropertyGetter()->getSelector().getAsString(); + else + OS << Node->getExplicitProperty()->getName(); } void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) { diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index d67f5fad6b..7f10bef713 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -866,22 +866,15 @@ void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) { void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) { VisitExpr(S); - VisitDecl(S->getProperty()); - if (S->isSuperReceiver()) { - ID.AddBoolean(S->isSuperReceiver()); - VisitType(S->getSuperType()); + if (S->isImplicitProperty()) { + VisitDecl(S->getImplicitPropertyGetter()); + VisitDecl(S->getImplicitPropertySetter()); + } else { + VisitDecl(S->getExplicitProperty()); } -} - -void StmtProfiler::VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *S) { - VisitExpr(S); - VisitDecl(S->getGetterMethod()); - VisitDecl(S->getSetterMethod()); - VisitDecl(S->getInterfaceDecl()); if (S->isSuperReceiver()) { ID.AddBoolean(S->isSuperReceiver()); - VisitType(S->getSuperType()); + VisitType(S->getSuperReceiverType()); } } diff --git a/lib/Checker/CheckObjCDealloc.cpp b/lib/Checker/CheckObjCDealloc.cpp index 11ddaca9d6..8ee6daa5c8 100644 --- a/lib/Checker/CheckObjCDealloc.cpp +++ b/lib/Checker/CheckObjCDealloc.cpp @@ -76,8 +76,8 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID, if (BinaryOperator* BO = dyn_cast<BinaryOperator>(S)) if (BO->isAssignmentOp()) if (ObjCPropertyRefExpr* PRE = - dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParenCasts())) - if (PRE->getProperty() == PD) + dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParenCasts())) + if (PRE->isExplicitProperty() && PRE->getExplicitProperty() == PD) if (BO->getRHS()->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull)) { // This is only a 'release' if the property kind is not diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index a552447b30..99dcdcff41 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -852,7 +852,6 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, case Stmt::ObjCAtFinallyStmtClass: case Stmt::ObjCAtTryStmtClass: case Stmt::ObjCEncodeExprClass: - case Stmt::ObjCImplicitSetterGetterRefExprClass: case Stmt::ObjCIsaExprClass: case Stmt::ObjCPropertyRefExprClass: case Stmt::ObjCProtocolExprClass: @@ -1221,7 +1220,6 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred, return; case Stmt::ObjCPropertyRefExprClass: - case Stmt::ObjCImplicitSetterGetterRefExprClass: // FIXME: Property assignments are lvalues, but not really "locations". // e.g.: self.x = something; // Here the "self.x" really can translate to a method call (setter) when @@ -3410,12 +3408,6 @@ void GRExprEngine::VisitBinaryOperator(const BinaryOperator* B, Expr* LHS = B->getLHS()->IgnoreParens(); Expr* RHS = B->getRHS()->IgnoreParens(); - // FIXME: Add proper support for ObjCImplicitSetterGetterRefExpr. - if (isa<ObjCImplicitSetterGetterRefExpr>(LHS)) { - Visit(RHS, Pred, Dst); - return; - } - if (B->isAssignmentOp()) VisitLValue(LHS, Pred, Tmp1); else diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 8f3e0a6326..b6cd1949cc 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -131,13 +131,6 @@ static void CollectBlockDeclRefInfo(const Stmt *S, CGBlockInfo &Info) { if (PE->isSuperReceiver()) Info.NeedsObjCSelf = true; } - else if (const ObjCImplicitSetterGetterRefExpr *IE = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(S)) { - // Getter/setter uses may also cause implicit super references, - // which we can check for with: - if (IE->isSuperReceiver()) - Info.NeedsObjCSelf = true; - } else if (isa<CXXThisExpr>(S)) Info.CXXThisRef = cast<CXXThisExpr>(S); } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 466f55f341..2db6cc8d31 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -549,8 +549,6 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { return EmitObjCIvarRefLValue(cast<ObjCIvarRefExpr>(E)); case Expr::ObjCPropertyRefExprClass: return EmitObjCPropertyRefLValue(cast<ObjCPropertyRefExpr>(E)); - case Expr::ObjCImplicitSetterGetterRefExprClass: - return EmitObjCKVCRefLValue(cast<ObjCImplicitSetterGetterRefExpr>(E)); case Expr::StmtExprClass: return EmitStmtExprLValue(cast<StmtExpr>(E)); case Expr::UnaryOperatorClass: @@ -1569,10 +1567,9 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { const PointerType *PTy = BaseExpr->getType()->getAs<PointerType>(); BaseQuals = PTy->getPointeeType().getQualifiers(); - } else if (isa<ObjCPropertyRefExpr>(BaseExpr->IgnoreParens()) || - isa<ObjCImplicitSetterGetterRefExpr>( - BaseExpr->IgnoreParens())) { - RValue RV = EmitObjCPropertyGet(BaseExpr); + } else if (ObjCPropertyRefExpr *PRE + = dyn_cast<ObjCPropertyRefExpr>(BaseExpr->IgnoreParens())) { + RValue RV = EmitObjCPropertyGet(PRE); BaseValue = RV.getAggregateAddr(); BaseQuals = BaseExpr->getType().getQualifiers(); } else { @@ -1796,7 +1793,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { RValue RV = LV.isPropertyRef() ? EmitLoadOfPropertyRefLValue(LV, QT) : EmitLoadOfKVCRefLValue(LV, QT); - assert(!RV.isScalar() && "EmitCastLValue-scalar cast of property ref"); + assert(RV.isAggregate()); llvm::Value *V = RV.getAggregateAddr(); return MakeAddrLValue(V, QT); } @@ -2107,16 +2104,12 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) { LValue CodeGenFunction::EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E) { - // This is a special l-value that just issues sends when we load or store - // through it. - return LValue::MakePropertyRef(E, E->getType().getCVRQualifiers()); -} + // This is a special l-value that just issues sends when we load or + // store through it. -LValue CodeGenFunction::EmitObjCKVCRefLValue( - const ObjCImplicitSetterGetterRefExpr *E) { - // This is a special l-value that just issues sends when we load or store - // through it. - return LValue::MakeKVCRef(E, E->getType().getCVRQualifiers()); + if (E->isImplicitProperty()) + return LValue::MakeKVCRef(E, E->getType().getCVRQualifiers()); + return LValue::MakePropertyRef(E, E->getType().getCVRQualifiers()); } LValue CodeGenFunction::EmitStmtExprLValue(const StmtExpr *E) { diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index bd1c43dff5..e19baa97f1 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -115,7 +115,6 @@ public: EmitAggLoadOfLValue(E); } void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E); - void VisitObjCImplicitSetterGetterRefExpr(ObjCImplicitSetterGetterRefExpr *E); void VisitConditionalOperator(const ConditionalOperator *CO); void VisitChooseExpr(const ChooseExpr *CE); @@ -354,12 +353,6 @@ void AggExprEmitter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { EmitGCMove(E, RV); } -void AggExprEmitter::VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *E) { - RValue RV = CGF.EmitObjCPropertyGet(E, getReturnValueSlot()); - EmitGCMove(E, RV); -} - void AggExprEmitter::VisitBinComma(const BinaryOperator *E) { CGF.EmitAnyExpr(E->getLHS(), AggValueSlot::ignored(), true); Visit(E->getRHS()); diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 26bda79898..5784825d6f 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -113,10 +113,6 @@ public: ComplexPairTy VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { return EmitLoadOfLValue(E); } - ComplexPairTy VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *E) { - return EmitLoadOfLValue(E); - } ComplexPairTy VisitObjCMessageExpr(ObjCMessageExpr *E) { return CGF.EmitObjCMessageExpr(E).getComplexVal(); } diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index a46afe6f65..ea23f2d6f2 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -239,10 +239,6 @@ public: Value *VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { return EmitLoadOfLValue(E); } - Value *VisitObjCImplicitSetterGetterRefExpr( - ObjCImplicitSetterGetterRefExpr *E) { - return EmitLoadOfLValue(E); - } Value *VisitObjCMessageExpr(ObjCMessageExpr *E) { return CGF.EmitObjCMessageExpr(E).getScalarVal(); } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 13f4d8f796..095f0cdde5 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -528,36 +528,34 @@ RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp, } -RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp, +RValue CodeGenFunction::EmitObjCPropertyGet(const ObjCPropertyRefExpr *E, ReturnValueSlot Return) { - Exp = Exp->IgnoreParens(); - // FIXME: Split it into two separate routines. - if (const ObjCPropertyRefExpr *E = dyn_cast<ObjCPropertyRefExpr>(Exp)) { - Selector S = E->getProperty()->getGetterName(); - if (E->isSuperReceiver()) - return EmitObjCSuperPropertyGet(E, S, Return); - return CGM.getObjCRuntime(). - GenerateMessageSend(*this, Return, Exp->getType(), S, - EmitScalarExpr(E->getBase()), - CallArgList()); + QualType ResultType; + Selector S; + if (E->isExplicitProperty()) { + const ObjCPropertyDecl *Property = E->getExplicitProperty(); + S = Property->getGetterName(); + ResultType = E->getType(); } else { - const ObjCImplicitSetterGetterRefExpr *KE = - cast<ObjCImplicitSetterGetterRefExpr>(Exp); - Selector S = KE->getGetterMethod()->getSelector(); - llvm::Value *Receiver; - if (KE->getInterfaceDecl()) { - const ObjCInterfaceDecl *OID = KE->getInterfaceDecl(); - Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); - } else if (KE->isSuperReceiver()) - return EmitObjCSuperPropertyGet(KE, S, Return); - else - Receiver = EmitScalarExpr(KE->getBase()); - return CGM.getObjCRuntime(). - GenerateMessageSend(*this, Return, - KE->getGetterMethod()->getResultType(), S, - Receiver, - CallArgList(), KE->getInterfaceDecl()); + const ObjCMethodDecl *Getter = E->getImplicitPropertyGetter(); + S = Getter->getSelector(); + ResultType = Getter->getResultType(); // with reference! } + + if (E->isSuperReceiver()) + return EmitObjCSuperPropertyGet(E, S, Return); + + llvm::Value *Receiver; + const ObjCInterfaceDecl *ReceiverClass = 0; + if (E->isClassReceiver()) { + ReceiverClass = E->getClassReceiver(); + Receiver = CGM.getObjCRuntime().GetClass(Builder, ReceiverClass); + } else { + Receiver = EmitScalarExpr(E->getBase()); + } + return CGM.getObjCRuntime(). + GenerateMessageSend(*this, Return, ResultType, S, + Receiver, CallArgList(), ReceiverClass); } void CodeGenFunction::EmitObjCSuperPropertySet(const Expr *Exp, @@ -581,43 +579,37 @@ void CodeGenFunction::EmitObjCSuperPropertySet(const Expr *Exp, return; } -void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp, +void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E, RValue Src) { - // FIXME: Split it into two separate routines. - if (const ObjCPropertyRefExpr *E = dyn_cast<ObjCPropertyRefExpr>(Exp)) { - Selector S = E->getProperty()->getSetterName(); - if (E->isSuperReceiver()) { - EmitObjCSuperPropertySet(E, S, Src); - return; - } - CallArgList Args; - Args.push_back(std::make_pair(Src, E->getType())); - CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), - getContext().VoidTy, S, - EmitScalarExpr(E->getBase()), - Args); - } else if (const ObjCImplicitSetterGetterRefExpr *E = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(Exp)) { - const ObjCMethodDecl *SetterMD = E->getSetterMethod(); - Selector S = SetterMD->getSelector(); - CallArgList Args; - llvm::Value *Receiver; - if (E->getInterfaceDecl()) { - const ObjCInterfaceDecl *OID = E->getInterfaceDecl(); - Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); - } else if (E->isSuperReceiver()) { - EmitObjCSuperPropertySet(E, S, Src); - return; - } else - Receiver = EmitScalarExpr(E->getBase()); - ObjCMethodDecl::param_iterator P = SetterMD->param_begin(); - Args.push_back(std::make_pair(Src, (*P)->getType())); - CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), - getContext().VoidTy, S, - Receiver, - Args, E->getInterfaceDecl()); - } else - assert (0 && "bad expression node in EmitObjCPropertySet"); + Selector S = E->getSetterSelector(); + QualType ArgType; + if (E->isImplicitProperty()) { + const ObjCMethodDecl *Setter = E->getImplicitPropertySetter(); + ObjCMethodDecl::param_iterator P = Setter->param_begin(); + ArgType = (*P)->getType(); + } else { + ArgType = E->getType(); + } + + if (E->isSuperReceiver()) { + EmitObjCSuperPropertySet(E, S, Src); + return; + } + + const ObjCInterfaceDecl *ReceiverClass = 0; + llvm::Value *Receiver; + if (E->isClassReceiver()) { + ReceiverClass = E->getClassReceiver(); + Receiver = CGM.getObjCRuntime().GetClass(Builder, ReceiverClass); + } else { + Receiver = EmitScalarExpr(E->getBase()); + } + + CallArgList Args; + Args.push_back(std::make_pair(Src, ArgType)); + CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), + getContext().VoidTy, S, + Receiver, Args, ReceiverClass); } void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index bb98c3cb23..2de5750084 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -25,7 +25,6 @@ namespace llvm { namespace clang { class ObjCPropertyRefExpr; - class ObjCImplicitSetterGetterRefExpr; namespace CodeGen { class CGBitFieldInfo; @@ -129,9 +128,6 @@ class LValue { // Obj-C property reference expression const ObjCPropertyRefExpr *PropertyRefExpr; - - // ObjC 'implicit' property reference expression - const ObjCImplicitSetterGetterRefExpr *KVCRefExpr; }; // 'const' is unused here @@ -255,9 +251,9 @@ public: } // 'implicit' property ref lvalue - const ObjCImplicitSetterGetterRefExpr *getKVCRefExpr() const { + const ObjCPropertyRefExpr *getKVCRefExpr() const { assert(isKVCRef()); - return KVCRefExpr; + return PropertyRefExpr; } static LValue MakeAddr(llvm::Value *V, QualType T, unsigned Alignment, @@ -321,11 +317,11 @@ public: return R; } - static LValue MakeKVCRef(const ObjCImplicitSetterGetterRefExpr *E, + static LValue MakeKVCRef(const ObjCPropertyRefExpr *E, unsigned CVR) { LValue R; R.LVType = KVCRef; - R.KVCRefExpr = E; + R.PropertyRefExpr = E; R.Initialize(Qualifiers::fromCVRMask(CVR)); return R; } diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 4bb5c595eb..4a58d5b357 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1460,7 +1460,6 @@ public: LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E); LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E); LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E); - LValue EmitObjCKVCRefLValue(const ObjCImplicitSetterGetterRefExpr *E); LValue EmitStmtExprLValue(const StmtExpr *E); LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E); LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E); @@ -1545,11 +1544,11 @@ public: llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E); RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return = ReturnValueSlot()); - RValue EmitObjCPropertyGet(const Expr *E, + RValue EmitObjCPropertyGet(const ObjCPropertyRefExpr *E, ReturnValueSlot Return = ReturnValueSlot()); RValue EmitObjCSuperPropertyGet(const Expr *Exp, const Selector &S, ReturnValueSlot Return = ReturnValueSlot()); - void EmitObjCPropertySet(const Expr *E, RValue Src); + void EmitObjCPropertySet(const ObjCPropertyRefExpr *E, RValue Src); void EmitObjCSuperPropertySet(const Expr *E, const Selector &S, RValue Src); diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index e9c51e8479..0d4cebf7d5 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1651,7 +1651,6 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) { case Expr::CompoundLiteralExprClass: case Expr::ExtVectorElementExprClass: case Expr::ObjCEncodeExprClass: - case Expr::ObjCImplicitSetterGetterRefExprClass: case Expr::ObjCIsaExprClass: case Expr::ObjCIvarRefExprClass: case Expr::ObjCMessageExprClass: diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 1ecde6a7fa..286ac0f638 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -1230,30 +1230,24 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(BinaryOperator *BinOp, Expr * SourceLocation SuperLocation; // Synthesize a ObjCMessageExpr from a ObjCPropertyRefExpr or ObjCImplicitSetterGetterRefExpr. // This allows us to reuse all the fun and games in SynthMessageExpr(). - if (ObjCPropertyRefExpr *PropRefExpr = dyn_cast<ObjCPropertyRefExpr>(BinOp->getLHS())) { - ObjCPropertyDecl *PDecl = PropRefExpr->getProperty(); - OMD = PDecl->getSetterMethodDecl(); - Ty = PDecl->getType(); - Sel = PDecl->getSetterName(); + if (ObjCPropertyRefExpr *PropRefExpr = + dyn_cast<ObjCPropertyRefExpr>(BinOp->getLHS())) { + if (PropRefExpr->isExplicitProperty()) { + ObjCPropertyDecl *PDecl = PropRefExpr->getExplicitProperty(); + OMD = PDecl->getSetterMethodDecl(); + Ty = PDecl->getType(); + Sel = PDecl->getSetterName(); + } else { + OMD = PropRefExpr->getImplicitPropertySetter(); + Sel = OMD->getSelector(); + Ty = PropRefExpr->getType(); + } Super = PropRefExpr->isSuperReceiver(); - if (!Super) + if (!Super) { Receiver = PropRefExpr->getBase(); - else { - SuperTy = PropRefExpr->getSuperType(); - SuperLocation = PropRefExpr->getSuperLocation(); - } - } - else if (ObjCImplicitSetterGetterRefExpr *ImplicitRefExpr = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(BinOp->getLHS())) { - OMD = ImplicitRefExpr->getSetterMethod(); - Sel = OMD->getSelector(); - Ty = ImplicitRefExpr->getType(); - Super = ImplicitRefExpr->isSuperReceiver(); - if (!Super) - Receiver = ImplicitRefExpr->getBase(); - else { - SuperTy = ImplicitRefExpr->getSuperType(); - SuperLocation = ImplicitRefExpr->getSuperLocation(); + } else { + SuperTy = PropRefExpr->getSuperReceiverType(); + SuperLocation = PropRefExpr->getReceiverLocation(); |