- Implement ivar rewrite (patch by Fariborz).
- RewriteMessageExpr()...make implicit casts explicit with synthesizing call (removing warnings when calling objc_msgSend()).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44156 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index e87ad6a..42961df 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -85,8 +85,12 @@
if (CurMethodDecl) {
ObjcInterfaceDecl *IFace = CurMethodDecl->getClassInterface();
ObjcInterfaceDecl *clsDeclared;
- if (ObjcIvarDecl *IV = IFace->lookupInstanceVariable(&II, clsDeclared))
- return new ObjCIvarRefExpr(IV, IV->getType(), Loc);
+ if (ObjcIvarDecl *IV = IFace->lookupInstanceVariable(&II, clsDeclared)) {
+ IdentifierInfo &II = Context.Idents.get("self");
+ ExprResult SelfExpr = ActOnIdentifierExpr(S, Loc, II, false);
+ return new ObjCIvarRefExpr(IV, IV->getType(), Loc,
+ static_cast<Expr*>(SelfExpr.Val), true, true);
+ }
}
// If this name wasn't predeclared and if this is not a function call,
// diagnose the problem.