[cfe-commits] r66045 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/ivar-access-tests.m
Steve Naroff
snaroff at apple.com
Wed Mar 4 10:34:24 PST 2009
Author: snaroff
Date: Wed Mar 4 12:34:24 2009
New Revision: 66045
URL: http://llvm.org/viewvc/llvm-project?rev=66045&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/ivar-access-tests.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=66045&r1=66044&r2=66045&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Mar 4 12:34:24 2009
@@ -1666,6 +1666,12 @@
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 @@
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
Modified: cfe/trunk/test/SemaObjC/ivar-access-tests.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ivar-access-tests.m?rev=66045&r1=66044&r2=66045&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/ivar-access-tests.m (original)
+++ cfe/trunk/test/SemaObjC/ivar-access-tests.m Wed Mar 4 12:34:24 2009
@@ -73,8 +73,50 @@
{
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;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at protocol NSObject - (BOOL)isEqual:(id)object;
+ at end
+ at protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end
+ at interface NSObject <NSObject> {}
+ at end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+ at interface NSResponder : NSObject <NSCoding> {}
+ at end
+ at protocol NSAnimatablePropertyContainer
+- (id)animator;
+ at end
+extern NSString *NSAnimationTriggerOrderIn ;
+ at interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+ struct __VFlags2 {
+ }
+ _vFlags2;
+}
+ at end
+ at class NSFontDescriptor, NSAffineTransform, NSGraphicsContext;
+ at interface NSScrollView : NSView {}
+ at end
+
+ at class CasperMixerView;
+ at interface CasperDiffScrollView : NSScrollView {
+ at private
+ CasperMixerView *_comparatorView;
+ NSView *someField;
+}
+ at end
+
+ at implementation CasperDiffScrollView
++ (void)initialize {}
+static void _CasperDiffScrollViewInstallMixerView(CasperDiffScrollView *scrollView) {
+ if (scrollView->someField != ((void *)0)) {
+ }
+}
+ at end
More information about the cfe-commits
mailing list