From 37a0260a5ffaaa859412426d883151224867b81c Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 14 Jan 2014 17:29:00 +0000 Subject: [PATCH] Use a proper lvalue-to-rvalue conversion in Objective-C++ property accessors. Previously, the synthesized AST contained an rvalue DeclRefExpr for 'self'. Now, it has an lvalue DeclRefExpr wrapped in an lvalue-to-rvalue ImplicitCastExpr, which is what's generated when an ivar access is written in the source. No (intended) functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199225 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaObjCProperty.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index f613b643ca..b1343301ef 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1148,12 +1148,15 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, ImplicitParamDecl *SelfDecl = getterMethod->getSelfDecl(); DeclRefExpr *SelfExpr = new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(), - VK_RValue, PropertyDiagLoc); + VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); + Expr *LoadSelfExpr = + ImplicitCastExpr::Create(Context, SelfDecl->getType(), + CK_LValueToRValue, SelfExpr, 0, VK_RValue); Expr *IvarRefExpr = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), PropertyDiagLoc, Ivar->getLocation(), - SelfExpr, true, true); + LoadSelfExpr, true, true); ExprResult Res = PerformCopyInitialization(InitializedEntity::InitializeResult( PropertyDiagLoc, @@ -1196,12 +1199,15 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, ImplicitParamDecl *SelfDecl = setterMethod->getSelfDecl(); DeclRefExpr *SelfExpr = new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(), - VK_RValue, PropertyDiagLoc); + VK_LValue, PropertyDiagLoc); MarkDeclRefReferenced(SelfExpr); + Expr *LoadSelfExpr = + ImplicitCastExpr::Create(Context, SelfDecl->getType(), + CK_LValueToRValue, SelfExpr, 0, VK_RValue); Expr *lhs = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), PropertyDiagLoc, Ivar->getLocation(), - SelfExpr, true, true); + LoadSelfExpr, true, true); ObjCMethodDecl::param_iterator P = setterMethod->param_begin(); ParmVarDecl *Param = (*P); QualType T = Param->getType().getNonReferenceType(); -- 2.40.0