This is an archive of the discontinued LLVM Phabricator instance.

[Objective-C] Fix __weak type traits with -fobjc-weak
ClosedPublic

Authored by bkelley on Mar 15 2017, 3:30 PM.

Details

Summary

Similar to ARC, in ObjCWeak Objective-C object pointers qualified with a weak lifetime are not POD or trivial types. Update the type trait code to reflect this. Copy and adapt the arc-type-traits.mm test case to verify correctness.

Diff Detail

Event Timeline

rjmccall edited edge metadata.Mar 16 2017, 9:36 AM

I have similar feedback here to the other patch. Please try to see if there's some reasonable way to make this dependent just on the lifetime qualifier without paying attention to the language options. If we, say, decide to start supporting __strong in non-ARC modes, it'd be nice if that just worked without having to revisit all of this code.

Looks like we can simplify everything by using hasNonTrivialObjCLifetime(), like in D31003.

bkelley updated this revision to Diff 92217.Mar 17 2017, 3:59 PM

Updated with feedback from @rjmccall

rjmccall added inline comments.Mar 20 2017, 11:00 PM
lib/AST/Type.cpp
2026–2027

Is the first condition not implied by the second?

bkelley updated this revision to Diff 92890.Mar 23 2017, 5:55 PM
bkelley marked an inline comment as done.

Removed redundant conditions, per feedback from @rjmccall

Thanks for the feedback! Apologies for the slow turn around; I was out sick :(

lib/AST/Type.cpp
2026–2027

It definitely is. Thanks!

rjmccall accepted this revision.Mar 24 2017, 8:40 AM

Looks great, thanks!

This revision is now accepted and ready to land.Mar 24 2017, 8:40 AM

Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks!

bkelley closed this revision.Mar 29 2017, 10:52 AM