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

Jordan Rose via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 15:42:33 PDT 2017


jordan_rose added a reviewer: rjmccall.
jordan_rose added a subscriber: rjmccall.
jordan_rose added a comment.

The warning-related parts look reasonable to me.



================
Comment at: lib/Sema/SemaDecl.cpp:10184
+         (!getLangOpts().ObjCAutoRefCount && getLangOpts().ObjCWeak &&
+          VDecl->getType().getObjCLifetime() != Qualifiers::OCL_Weak)) &&
         !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
----------------
This condition's getting complicated, and it shows up in a few places. Would it make sense to factor it out?


================
Comment at: lib/Sema/SemaExpr.cpp:707
   // balance that.
-  if (getLangOpts().ObjCAutoRefCount &&
+  if ((getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) &&
       E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
----------------
This is the one section that //isn't// dealing with the warning. I'd like @rjmccall to verify that it's correct.


================
Comment at: lib/Sema/SemaExpr.cpp:10340
 
-      } else if (getLangOpts().ObjCAutoRefCount) {
+      } else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
         checkUnsafeExprAssigns(Loc, LHSExpr, RHS.get());
----------------
Does ObjCAutoRefCount imply ObjCWeak? If so, you could just use the latter.


https://reviews.llvm.org/D31005





More information about the cfe-commits mailing list