From: Jordan Rose Date: Thu, 11 Oct 2012 17:02:00 +0000 (+0000) Subject: -Warc-repeated-use-of-weak: fix a use-of-uninitialized and add a test case. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1c1ba089cd8930c1193fcd20fb38cab834a8f94;p=clang -Warc-repeated-use-of-weak: fix a use-of-uninitialized and add a test case. Fix-up for r165718, should get the buildbots back online. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165723 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/ScopeInfo.cpp b/lib/Sema/ScopeInfo.cpp index c1d6629905..4d29a34a73 100644 --- a/lib/Sema/ScopeInfo.cpp +++ b/lib/Sema/ScopeInfo.cpp @@ -159,7 +159,7 @@ void FunctionScopeInfo::markSafeWeakUse(const Expr *E) { Uses = WeakObjectUses.find(WeakObjectProfileTy(IvarE)); else if (const DeclRefExpr *DRE = dyn_cast(E)) Uses = WeakObjectUses.find(WeakObjectProfileTy(DRE)); - else if (const ObjCMessageExpr *MsgE = dyn_cast(MsgE)) { + else if (const ObjCMessageExpr *MsgE = dyn_cast(E)) { Uses = WeakObjectUses.end(); if (const ObjCMethodDecl *MD = MsgE->getMethodDecl()) { if (const ObjCPropertyDecl *Prop = MD->findPropertyDecl()) { diff --git a/test/SemaObjC/arc-repeated-weak.mm b/test/SemaObjC/arc-repeated-weak.mm index a59f435693..1539a9bcae 100644 --- a/test/SemaObjC/arc-repeated-weak.mm +++ b/test/SemaObjC/arc-repeated-weak.mm @@ -181,6 +181,18 @@ void assignToStrongWithCasts(Test *a) { } } +void assignToStrongWithMessages(Test *a) { + if (condition()) { + id val = [a weakProp]; // no-warning + (void)val; + } else { + id val; + val = [a weakProp]; // no-warning + (void)val; + } +} + + void assignAfterRead(Test *a) { // Special exception for a single read before any writes. if (!a.weakProp) // no-warning