[cfe-commits] r161500 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaExprMember.cpp test/SemaObjC/warn-direct-ivar-access.m
Fariborz Jahanian
fjahanian at apple.com
Wed Aug 8 09:41:04 PDT 2012
Author: fjahanian
Date: Wed Aug 8 11:41:04 2012
New Revision: 161500
URL: http://llvm.org/viewvc/llvm-project?rev=161500&view=rev
Log:
objc: Include all types when issuing warning under
-Wdirect-ivar-access.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaObjC/warn-direct-ivar-access.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=161500&r1=161499&r2=161500&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug 8 11:41:04 2012
@@ -1961,11 +1961,10 @@
return ExprError();
MarkAnyDeclReferenced(Loc, IV);
- if (IV->getType()->isObjCObjectPointerType()) {
- ObjCMethodFamily MF = CurMethod->getMethodFamily();
- if (MF != OMF_init && MF != OMF_dealloc && MF != OMF_finalize)
- Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
- }
+
+ 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));
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=161500&r1=161499&r2=161500&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Wed Aug 8 11:41:04 2012
@@ -1263,7 +1263,7 @@
warn = false;
}
}
- if (warn && IV->getType()->isObjCObjectPointerType()) {
+ if (warn) {
if (ObjCMethodDecl *MD = getCurMethodDecl()) {
ObjCMethodFamily MF = MD->getMethodFamily();
warn = (MF != OMF_init && MF != OMF_dealloc &&
Modified: cfe/trunk/test/SemaObjC/warn-direct-ivar-access.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-direct-ivar-access.m?rev=161500&r1=161499&r2=161500&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/warn-direct-ivar-access.m (original)
+++ cfe/trunk/test/SemaObjC/warn-direct-ivar-access.m Wed Aug 8 11:41:04 2012
@@ -5,15 +5,18 @@
@public
id _myMaster;
id _isTickledPink;
+ int _myIntProp;
}
@property(retain) id myMaster;
@property(assign) id isTickledPink; // expected-note {{property declared here}}
+ at property int myIntProp;
@end
@implementation MyObject
@synthesize myMaster = _myMaster;
@synthesize isTickledPink = _isTickledPink; // expected-error {{existing ivar '_isTickledPink' for property 'isTickledPink'}}
+ at synthesize myIntProp = _myIntProp;
- (void) doSomething {
_myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \
@@ -33,6 +36,8 @@
p.isTickledPink = p.myMaster; // ok
p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \
// expected-warning {{instance variable '_myMaster' is being directly accessed}}
+ if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
+ p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}}
return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}}
}
More information about the cfe-commits
mailing list