summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-08-06 23:50:51 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-08-06 23:50:51 +0000
commit14f1aa70a9fae2e57f1eb91b6769cd92dc6dc0db (patch)
treed49082f0fb80e26c53dc755ea7ed84a64d4aedc9 /clang/lib
parent6297fa8a140a47fc0237b7d884d554a99239e957 (diff)
downloadbcm5719-llvm-14f1aa70a9fae2e57f1eb91b6769cd92dc6dc0db.tar.gz
bcm5719-llvm-14f1aa70a9fae2e57f1eb91b6769cd92dc6dc0db.zip
objective-c: Implement gcc's -Wdirect-ivar-access option.
// rdar://6505197 llvm-svn: 161362
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
-rw-r--r--clang/lib/Sema/SemaExprMember.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea121b8b3ce..e8ba54d24fb 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1961,6 +1961,9 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
return ExprError();
MarkAnyDeclReferenced(Loc, IV);
+ if (IV->getType()->isObjCObjectPointerType() &&
+ getLangOpts().getGC() == LangOptions::NonGC)
+ Diag(Loc, diag::warn_direct_ivar_access) << IV->getDeclName();
return Owned(new (Context)
ObjCIvarRefExpr(IV, IV->getType(), Loc,
SelfExpr.take(), true, true));
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 79973b352fe..5a116b44964 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1260,7 +1260,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
Diag(DE->getLocation(), diag::error_arc_weak_ivar_access);
}
-
+ if (IV->getType()->isObjCObjectPointerType() &&
+ getLangOpts().getGC() == LangOptions::NonGC)
+ Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(),
MemberLoc, BaseExpr.take(),
IsArrow));
OpenPOWER on IntegriCloud