forked from OSchip/llvm-project
objective-c: Exclude -Wdirect-ivar-access for arc.
Allow direct ivar access in init and dealloc methods in mrr. // rdar://650197 llvm-svn: 161426
This commit is contained in:
parent
59fba12d28
commit
a7c9f883e6
|
@ -1962,8 +1962,12 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
|
|||
|
||||
MarkAnyDeclReferenced(Loc, IV);
|
||||
if (IV->getType()->isObjCObjectPointerType() &&
|
||||
getLangOpts().getGC() == LangOptions::NonGC)
|
||||
Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
|
||||
getLangOpts().getGC() == LangOptions::NonGC &&
|
||||
!getLangOpts().ObjCAutoRefCount) {
|
||||
ObjCMethodFamily MF = CurMethod->getMethodFamily();
|
||||
if (MF != OMF_init && MF != OMF_dealloc && MF != OMF_finalize)
|
||||
Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
|
||||
}
|
||||
return Owned(new (Context)
|
||||
ObjCIvarRefExpr(IV, IV->getType(), Loc,
|
||||
SelfExpr.take(), true, true));
|
||||
|
|
|
@ -1261,8 +1261,17 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
|||
Diag(DE->getLocation(), diag::error_arc_weak_ivar_access);
|
||||
}
|
||||
if (IV->getType()->isObjCObjectPointerType() &&
|
||||
getLangOpts().getGC() == LangOptions::NonGC)
|
||||
Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
|
||||
getLangOpts().getGC() == LangOptions::NonGC &&
|
||||
!getLangOpts().ObjCAutoRefCount) {
|
||||
bool warn = true;
|
||||
if (ObjCMethodDecl *MD = getCurMethodDecl()) {
|
||||
ObjCMethodFamily MF = MD->getMethodFamily();
|
||||
warn = (MF != OMF_init && MF != OMF_dealloc &&
|
||||
MF != OMF_finalize);
|
||||
}
|
||||
if (warn)
|
||||
Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
|
||||
}
|
||||
return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(),
|
||||
MemberLoc, BaseExpr.take(),
|
||||
IsArrow));
|
||||
|
|
|
@ -20,6 +20,11 @@ __attribute__((objc_root_class)) @interface MyObject {
|
|||
// expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
|
||||
}
|
||||
|
||||
- (id) init {
|
||||
_myMaster=0;
|
||||
return _myMaster;
|
||||
}
|
||||
- (void) dealloc { _myMaster = 0; }
|
||||
@end
|
||||
|
||||
MyObject * foo ()
|
||||
|
|
Loading…
Reference in New Issue