[cfe-commits] r64644 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/attr-deprecated.m
Chris Lattner
sabre at nondot.org
Mon Feb 16 10:35:08 PST 2009
Author: lattner
Date: Mon Feb 16 12:35:08 2009
New Revision: 64644
URL: http://llvm.org/viewvc/llvm-project?rev=64644&view=rev
Log:
Add support for deprecating ObjC properties. Unlike GCC, we warn that the
property is deprecated, not the getter/setter if the attribute is on
the property.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=64644&r1=64643&r2=64644&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 16 12:35:08 2009
@@ -1683,16 +1683,24 @@
ObjCInterfaceDecl *IFace = IFTy->getDecl();
// Search for a declared property first.
- if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(&Member))
+ if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(&Member)) {
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(PD, MemberLoc);
+
return Owned(new (Context) ObjCPropertyRefExpr(PD, PD->getType(),
- MemberLoc, BaseExpr));
+ MemberLoc, BaseExpr));
+ }
// Check protocols on qualified interfaces.
for (ObjCInterfaceType::qual_iterator I = IFTy->qual_begin(),
E = IFTy->qual_end(); I != E; ++I)
- if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member))
+ if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) {
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(PD, MemberLoc);
+
return Owned(new (Context) ObjCPropertyRefExpr(PD, PD->getType(),
- MemberLoc, BaseExpr));
+ MemberLoc, BaseExpr));
+ }
// If that failed, look for an "implicit" property by seeing if the nullary
// selector is implemented.
@@ -1719,6 +1727,9 @@
}
}
if (Getter) {
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(Getter, MemberLoc);
+
// If we found a getter then this may be a valid dot-reference, we
// will look for the matching setter, in case it is needed.
IdentifierInfo *SetterName = constructSetterName(PP.getIdentifierTable(),
@@ -1742,6 +1753,11 @@
}
}
+ if (Setter)
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(Setter, MemberLoc);
+
+
// FIXME: we must check that the setter has property type.
return Owned(new (Context) ObjCKVCRefExpr(Getter, Getter->getResultType(),
Setter, MemberLoc, BaseExpr));
@@ -1756,12 +1772,19 @@
// Check protocols on qualified interfaces.
for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(),
E = QIdTy->qual_end(); I != E; ++I) {
- if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member))
+ if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member)) {
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(PD, MemberLoc);
+
return Owned(new (Context) ObjCPropertyRefExpr(PD, PD->getType(),
- MemberLoc, BaseExpr));
+ MemberLoc, BaseExpr));
+ }
// Also must look for a getter name which uses property syntax.
Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Sel)) {
+ // Check if referencing a property with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(OMD, MemberLoc);
+
return Owned(new (Context) ObjCMessageExpr(BaseExpr, Sel,
OMD->getResultType(), OMD, OpLoc, MemberLoc, NULL, 0));
}
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=64644&r1=64643&r2=64644&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Mon Feb 16 12:35:08 2009
@@ -67,3 +67,18 @@
[c F];
}
+
+
+ at interface Bar
+
+ at property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
+- (void) MySetter : (int) value;
+ at end
+
+int t5() {
+ Bar *f;
+ f.FooBar = 1; // expected-warning {{warning: 'FooBar' is deprecated}}
+ return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
+}
+
+
More information about the cfe-commits
mailing list