r199225 - Use a proper lvalue-to-rvalue conversion in Objective-C++ property accessors.

Jordan Rose jordan_rose at apple.com
Tue Jan 14 09:29:00 PST 2014


Author: jrose
Date: Tue Jan 14 11:29:00 2014
New Revision: 199225

URL: http://llvm.org/viewvc/llvm-project?rev=199225&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=199225&r1=199224&r2=199225&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Jan 14 11:29:00 2014
@@ -1148,12 +1148,15 @@ Decl *Sema::ActOnPropertyImplDecl(Scope
       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
       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();





More information about the cfe-commits mailing list