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.

llvm-svn: 199225
This commit is contained in:
Jordan Rose 2014-01-14 17:29:00 +00:00
parent b183f8594f
commit 31c05a117a
1 changed files with 10 additions and 4 deletions

View File

@ -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();