[cfe-commits] r64637 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/attr-deprecated.c test/SemaObjC/attr-deprecated.m
Chris Lattner
sabre at nondot.org
Mon Feb 16 09:19:13 PST 2009
Author: lattner
Date: Mon Feb 16 11:19:12 2009
New Revision: 64637
URL: http://llvm.org/viewvc/llvm-project?rev=64637&view=rev
Log:
add support for deprecated objc ivars.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-deprecated.c
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=64637&r1=64636&r2=64637&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 16 11:19:12 2009
@@ -600,6 +600,9 @@
if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) {
ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II)) {
+ // Check if referencing a field with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(IV, Loc);
+
// FIXME: This should use a new expr for a direct reference, don't turn
// this into Self->ivar, just return a BareIVarExpr or something.
IdentifierInfo &II = Context.Idents.get("self");
@@ -771,6 +774,9 @@
DiagnoseUseOfDeprecatedDecl(VD, Loc);
if (VarDecl *Var = dyn_cast<VarDecl>(VD)) {
+ // Warn about constructs like:
+ // if (void *X = foo()) { ... } else { X }.
+ // In the else block, the pointer is always false.
if (Var->isDeclaredInCondition() && Var->getType()->isScalarType()) {
Scope *CheckS = S;
while (CheckS) {
@@ -1654,6 +1660,9 @@
if (IV->isInvalidDecl())
return ExprError();
+ // Check if referencing a field with __attribute__((deprecated)).
+ DiagnoseUseOfDeprecatedDecl(IV, MemberLoc);
+
ObjCIvarRefExpr *MRef= new (Context) ObjCIvarRefExpr(IV, IV->getType(),
MemberLoc, BaseExpr,
OpKind == tok::arrow);
Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=64637&r1=64636&r2=64637&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Mon Feb 16 11:19:12 2009
@@ -40,3 +40,4 @@
void test1(struct foo *F) {
++F->x; // expected-warning {{'x' is deprecated}}
}
+
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=64637&r1=64636&r2=64637&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Mon Feb 16 11:19:12 2009
@@ -1,6 +1,8 @@
// RUN: clang %s -fsyntax-only -verify
- at interface A
+ at interface A {
+ int X __attribute__((deprecated));
+}
+ (void)F __attribute__((deprecated));
- (void)f __attribute__((deprecated));
@end
@@ -13,6 +15,8 @@
- (void)g
{
+ X++; // expected-warning{{'X' is deprecated}}
+ self->X++; // expected-warning{{'X' is deprecated}}
[self f]; // expected-warning{{'f' is deprecated}}
}
More information about the cfe-commits
mailing list