[PATCH] D31005: [Objective-C] Fix "repeated use of weak" warning with -fobjc-weak

Brian T. Kelley via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 16:10:15 PDT 2017

bkelley added inline comments.

Comment at: lib/Sema/SemaDecl.cpp:10184
+         (!getLangOpts().ObjCAutoRefCount && getLangOpts().ObjCWeak &&
+          VDecl->getType().getObjCLifetime() != Qualifiers::OCL_Weak)) &&
jordan_rose wrote:
> This condition's getting complicated, and it shows up in a few places. Would it make sense to factor it out?
What do you think about adding a member function like `hasMRCNonTrivialWeakObjCLifetime(const ASTContext &Context)` to QualType to factor out lines 10183-10184? We could use that in D31003, D31004, here, and D31007.

Comment at: lib/Sema/SemaExpr.cpp:10340
-      } else if (getLangOpts().ObjCAutoRefCount) {
+      } else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
         checkUnsafeExprAssigns(Loc, LHSExpr, RHS.get());
jordan_rose wrote:
> Does ObjCAutoRefCount imply ObjCWeak? If so, you could just use the latter.
I don't believe so. For Snow Leopard, ARC without weak references was supported so they can be independent. 


More information about the cfe-commits mailing list