[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 17:05:23 PDT 2017


jordan_rose added inline comments.


================
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,
----------------
bkelley wrote:
> 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.
I'm fine with it myself but I don't work on Clang very much anymore. Maybe someone else can say whether it's actually a good idea.

(By the way, the conventional abbreviation for this mode is "MRR" for "Manual Retain/Release", even though it's "ARC" and "Automated Reference Counting".)


================
Comment at: lib/Sema/SemaExpr.cpp:10340
 
-      } else if (getLangOpts().ObjCAutoRefCount) {
+      } else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
         checkUnsafeExprAssigns(Loc, LHSExpr, RHS.get());
----------------
bkelley wrote:
> 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. 
Sure, but in that case we don't need the warning, right?


https://reviews.llvm.org/D31005





More information about the cfe-commits mailing list