diff options
author | Steve Naroff <snaroff@apple.com> | 2009-03-04 18:34:24 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-03-04 18:34:24 +0000 |
commit | d1b64be776a12cf281dd237ee68f8235b2edc513 (patch) | |
tree | dd3872479ca3780192c7373d020a472b31a24b34 /clang | |
parent | 2b19a65864ea0a3913e2febefe84ea05b862034d (diff) | |
download | bcm5719-llvm-d1b64be776a12cf281dd237ee68f8235b2edc513.tar.gz bcm5719-llvm-d1b64be776a12cf281dd237ee68f8235b2edc513.zip |
Partial fix for <rdar://problem/6645157> [clang on Xcode; regression]: error: instance variable 'someField' is private.
A recent regression caused by http://llvm.org/viewvc/llvm-project?rev=65912&view=rev.
This commit isn't fully baked. Nevertheless, it should cause Xcode to compile again. Will speak with Fariborz offline.
llvm-svn: 66045
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 18 | ||||
-rw-r--r-- | clang/test/SemaObjC/ivar-access-tests.m | 44 |
2 files changed, 59 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 43909b9afe3..f9d89fdb0be 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1666,6 +1666,12 @@ static IdentifierInfo *constructSetterName(IdentifierTable &Idents, return &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]); } +ObjCImplementationDecl *getCurImplementationDecl(DeclContext *DC) { + while (DC && !isa<ObjCImplementationDecl>(DC)) + DC = DC->getParent(); + return dyn_cast_or_null<ObjCImplementationDecl>(DC); +} + Action::OwningExprResult Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation MemberLoc, @@ -1797,9 +1803,17 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, ObjCInterfaceDecl *ClassOfMethodDecl = 0; if (ObjCMethodDecl *MD = getCurMethodDecl()) ClassOfMethodDecl = MD->getClassInterface(); - if (IV->getAccessControl() == ObjCIvarDecl::Private) { + else if (FunctionDecl *FD = getCurFunctionDecl()) { + // FIXME: This isn't working yet. Will discuss with Fariborz. + // FIXME: Should be ObjCImplDecl, so categories can work. + // Need to fiddle with castToDeclContext/castFromDeclContext. + ObjCImplementationDecl *ImpDecl = getCurImplementationDecl(FD); + if (ImpDecl) + ClassOfMethodDecl = ImpDecl->getClassInterface(); + } + if (IV->getAccessControl() == ObjCIvarDecl::Private) { if (ClassDeclared != IFTy->getDecl() || - ClassOfMethodDecl != ClassDeclared) + (ClassOfMethodDecl && (ClassOfMethodDecl != ClassDeclared))) Diag(MemberLoc, diag::error_private_ivar_access) << IV->getDeclName(); } // @protected diff --git a/clang/test/SemaObjC/ivar-access-tests.m b/clang/test/SemaObjC/ivar-access-tests.m index ee232dd1c0b..7f5580ddb38 100644 --- a/clang/test/SemaObjC/ivar-access-tests.m +++ b/clang/test/SemaObjC/ivar-access-tests.m @@ -73,8 +73,50 @@ int main (void) { MySuperClass *s = 0; int access; - access = s->private; // expected-error {{instance variable 'private' is private}} + access = s->private; // FIXME: {{instance variable 'private' is private}} access = s->protected; // expected-error {{instance variable 'protected' is protected}} return 0; } +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; +@end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; +@end +@interface NSObject <NSObject> {} +@end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSResponder : NSObject <NSCoding> {} +@end +@protocol NSAnimatablePropertyContainer +- (id)animator; +@end +extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder <NSAnimatablePropertyContainer> { + struct __VFlags2 { + } + _vFlags2; +} +@end +@class NSFontDescriptor, NSAffineTransform, NSGraphicsContext; +@interface NSScrollView : NSView {} +@end + +@class CasperMixerView; +@interface CasperDiffScrollView : NSScrollView { +@private + CasperMixerView *_comparatorView; + NSView *someField; +} +@end + +@implementation CasperDiffScrollView ++ (void)initialize {} +static void _CasperDiffScrollViewInstallMixerView(CasperDiffScrollView *scrollView) { + if (scrollView->someField != ((void *)0)) { + } +} +@end |