diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-10 19:28:26 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-01-10 19:28:26 +0000 |
| commit | edbc3451706ab8a23e17774cd52a3efba6e1e53b (patch) | |
| tree | f7a2304dd91579348343d29395c205aefe88b154 /clang/lib/Sema | |
| parent | 3f1035410f50560ce714c0f298fff0ce83b08fe3 (diff) | |
| download | bcm5719-llvm-edbc3451706ab8a23e17774cd52a3efba6e1e53b.tar.gz bcm5719-llvm-edbc3451706ab8a23e17774cd52a3efba6e1e53b.zip | |
objc-arc: fixes a crash when trying to find out retaining cycle
ownership of property sent to 'super'. // rdar://10640891
llvm-svn: 147868
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 73ff49a3389..dc9ce076ea1 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4458,7 +4458,7 @@ static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner) { return true; } -static bool findRetainCycleOwner(Expr *e, RetainCycleOwner &owner) { +static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) { while (true) { e = e->IgnoreParens(); if (CastExpr *cast = dyn_cast<CastExpr>(e)) { @@ -4481,7 +4481,7 @@ static bool findRetainCycleOwner(Expr *e, RetainCycleOwner &owner) { return false; // Try to find a retain cycle in the base. - if (!findRetainCycleOwner(ref->getBase(), owner)) + if (!findRetainCycleOwner(S, ref->getBase(), owner)) return false; if (ref->isFreeIvar()) owner.setLocsFrom(ref); @@ -4524,6 +4524,14 @@ static bool findRetainCycleOwner(Expr *e, RetainCycleOwner &owner) { return false; owner.Indirect = true; + if (pre->isSuperReceiver()) { + owner.Variable = S.getCurMethodDecl()->getSelfDecl(); + if (!owner.Variable) + return false; + owner.Loc = pre->getLocation(); + owner.Range = pre->getSourceRange(); + return true; + } e = const_cast<Expr*>(cast<OpaqueValueExpr>(pre->getBase()) ->getSourceExpr()); continue; @@ -4626,7 +4634,7 @@ void Sema::checkRetainCycles(ObjCMessageExpr *msg) { // Try to find a variable that the receiver is strongly owned by. RetainCycleOwner owner; if (msg->getReceiverKind() == ObjCMessageExpr::Instance) { - if (!findRetainCycleOwner(msg->getInstanceReceiver(), owner)) + if (!findRetainCycleOwner(*this, msg->getInstanceReceiver(), owner)) return; } else { assert(msg->getReceiverKind() == ObjCMessageExpr::SuperInstance); @@ -4644,7 +4652,7 @@ void Sema::checkRetainCycles(ObjCMessageExpr *msg) { /// Check a property assign to see if it's likely to cause a retain cycle. void Sema::checkRetainCycles(Expr *receiver, Expr *argument) { RetainCycleOwner owner; - if (!findRetainCycleOwner(receiver, owner)) + if (!findRetainCycleOwner(*this, receiver, owner)) return; if (Expr *capturer = findCapturingExpr(*this, argument, owner)) |

