[cfe-commits] r152187 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaExprMember.cpp test/SemaObjC/no-ivar-access-control.m
Fariborz Jahanian
fjahanian at apple.com
Tue Mar 6 16:58:42 PST 2012
Author: fjahanian
Date: Tue Mar 6 18:58:41 2012
New Revision: 152187
URL: http://llvm.org/viewvc/llvm-project?rev=152187&view=rev
Log:
objective-c lldb support: don't perform ivar access control check
when debugging. // rdar://10997647
Added:
cfe/trunk/test/SemaObjC/no-ivar-access-control.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=152187&r1=152186&r2=152187&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 6 18:58:41 2012
@@ -1748,7 +1748,8 @@
// Diagnose the use of an ivar outside of the declaring class.
if (IV->getAccessControl() == ObjCIvarDecl::Private &&
- !declaresSameEntity(ClassDeclared, IFace))
+ !declaresSameEntity(ClassDeclared, IFace) &&
+ !getLangOptions().DebuggerSupport)
Diag(Loc, diag::error_private_ivar_access) << IV->getDeclName();
// FIXME: This should use a new expr for a direct reference, don't
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=152187&r1=152186&r2=152187&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 6 18:58:41 2012
@@ -1189,16 +1189,17 @@
dyn_cast<ObjCCategoryImplDecl>(ObjCImpDecl))
ClassOfMethodDecl = CatImplClass->getClassInterface();
}
-
- if (IV->getAccessControl() == ObjCIvarDecl::Private) {
- if (!declaresSameEntity(ClassDeclared, IDecl) ||
- !declaresSameEntity(ClassOfMethodDecl, ClassDeclared))
- Diag(MemberLoc, diag::error_private_ivar_access)
+ if (!getLangOptions().DebuggerSupport) {
+ if (IV->getAccessControl() == ObjCIvarDecl::Private) {
+ if (!declaresSameEntity(ClassDeclared, IDecl) ||
+ !declaresSameEntity(ClassOfMethodDecl, ClassDeclared))
+ Diag(MemberLoc, diag::error_private_ivar_access)
+ << IV->getDeclName();
+ } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
+ // @protected
+ Diag(MemberLoc, diag::error_protected_ivar_access)
<< IV->getDeclName();
- } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
- // @protected
- Diag(MemberLoc, diag::error_protected_ivar_access)
- << IV->getDeclName();
+ }
}
if (getLangOptions().ObjCAutoRefCount) {
Expr *BaseExp = BaseExpr.get()->IgnoreParenImpCasts();
Added: cfe/trunk/test/SemaObjC/no-ivar-access-control.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/no-ivar-access-control.m?rev=152187&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/no-ivar-access-control.m (added)
+++ cfe/trunk/test/SemaObjC/no-ivar-access-control.m Tue Mar 6 18:58:41 2012
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fdebugger-support -fsyntax-only -verify %s
+// rdar://10997647
+
+ at interface I
+{
+ at private
+int ivar;
+}
+ at end
+
+ at implementation I
+- (int) meth {
+ return self->ivar;
+}
+int foo1(I* p) {
+ return p->ivar;
+}
+ at end
+
+int foo(I* p) {
+ return p->ivar;
+}
+
+ at interface B
+ at end
+
+ at implementation B
+- (int) meth : (I*) arg {
+ return arg->ivar;
+}
+ at end
+
+
+ at interface I1 {
+ int protected_ivar;
+}
+ at property int PROP_INMAIN;
+ at end
+
+ at interface I1() {
+ int private_ivar;
+}
+ at property int PROP_INCLASSEXT;
+ at end
+
+ at implementation I1
+ at synthesize PROP_INMAIN, PROP_INCLASSEXT;
+
+- (int) Meth {
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ protected_ivar = 1; // OK
+ return private_ivar; // OK
+}
+ at end
+
+
+ at interface DER : I1
+ at end
+
+ at implementation DER
+- (int) Meth {
+ protected_ivar = 1; // OK
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ return private_ivar;
+}
+ at end
+
More information about the cfe-commits
mailing list