[Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak
authorBrian Kelley <bkelley@microsoft.com>
Wed, 29 Mar 2017 17:31:42 +0000 (17:31 +0000)
committerBrian Kelley <bkelley@microsoft.com>
Wed, 29 Mar 2017 17:31:42 +0000 (17:31 +0000)
commit036603ac59d7818be878176870b3116ee56f5574
tree82fecc28cf2e8e9bca497d3f8edc019f43465e53
parent4afdfe811ca2aeed7cdd2bf324a922098c8ef8e2
[Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak

Summary: When adding an Objective-C retainable type member to a C++ class, also check the LangOpts.ObjCWeak flag and the lifetime qualifier so __weak qualified Objective-C pointer members cause the class to be a non-POD type with non-trivial special members, so the compiler always emits the necessary runtime calls for copying, moving, and destroying the weak member. Otherwise, Objective-C++ classes with weak Objective-C pointer members compiled with -fobjc-weak exhibit undefined behavior if the C++ class is classified as a POD type.

Reviewers: rsmith, benlangmuir, doug.gregor, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31003

llvm-svn: 299008
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenObjCXX/objc-weak.mm [new file with mode: 0644]