[PATCH] D31003: [Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak

Brian T. Kelley via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 17 16:05:24 PDT 2017


bkelley marked 2 inline comments as done.
bkelley added inline comments.


================
Comment at: lib/Sema/SemaDeclCXX.cpp:4407
+       (SemaRef.getLangOpts().ObjCWeak &&
+        FieldBaseElementType.getObjCLifetime() == Qualifiers::OCL_Weak))) {
+    // ARC and Weak:
----------------
rjmccall wrote:
> I think this entire check can just be:
> 
>   if (FieldBaseElementType.hasNonTrivialObjCLifetime())
> 
> The language-options checks are almost certainly slower than just checking the qualifiers.
I see. `handleObjCOwnershipTypeAttr()` in SemaType.cpp only adds `OCL_Weak` or `OCL_ExplicitNone` outside of ARC and it's a compile error to use `__weak` without -fobjc-arc or -fobjc-weak, so `hasNonTrivialObjCLifetime()` is indeed much more simple. Thanks!


https://reviews.llvm.org/D31003





More information about the cfe-commits mailing list