add support for deprecated objc ivars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64637 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 66f33c1..49bba1d 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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);