]> granicus.if.org Git - clang/commit
[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)
commitb18f3efe980fabecca8feac4bd1512e4e9c33d57
treeb00a986834fb1c85e4482440862b8ca38c8d1fb6
parent1895a41dddbc05cdcfeb06ab7cb8f3e73679b30b
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299008 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/DeclCXX.cpp
lib/Sema/SemaDeclCXX.cpp
test/CodeGenObjCXX/objc-weak.mm [new file with mode: 0644]