diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-16 17:29:56 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-16 17:29:56 +0000 |
commit | b1f7d2496a2916cfad17633e403151dd09118821 (patch) | |
tree | 03dee6854a8307ee80f33eb3471c3676587ad7b3 /lib/Sema/SemaExpr.cpp | |
parent | 952105343c34a5ce5e740c7518710f7af1e368ec (diff) |
arc: diagnose dereferencing a __weak pointer which may be
null at any time. // rdar://9612030
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 3122d42cdb..5e30e7179c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4333,6 +4333,16 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, Diag(MemberLoc, diag::error_protected_ivar_access) << IV->getDeclName(); } + if (getLangOptions().ObjCAutoRefCount) { + Expr *BaseExp = BaseExpr.get()->IgnoreParenImpCasts(); + if (UnaryOperator *UO = dyn_cast<UnaryOperator>(BaseExp)) + if (UO->getOpcode() == UO_Deref) + BaseExp = UO->getSubExpr()->IgnoreParenCasts(); + + if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(BaseExp)) + if (DE->getType().getObjCLifetime() == Qualifiers::OCL_Weak) + Diag(DE->getLocation(), diag::error_arc_weak_ivar_access); + } return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr.take(), |