[PATCH] D31003: [Objective-C] C++ Classes with __weak Members non-POD Types when using -fobjc-weak
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 16 09:33:33 PDT 2017
rjmccall added inline comments.
================
Comment at: lib/AST/DeclCXX.cpp:727
+ !(Context.getLangOpts().ObjCWeak &&
+ T.getObjCLifetime() == Qualifiers::OCL_Weak)) {
setHasObjectMember(true);
----------------
Similarly, I think the best way of expressing this is to re-arrange the blocks like so:
if (T.hasNonTrivialObjCLifetime()) {
// Objective-C Automatic Reference Counting:
// If a class has a non-static data member of Objective-C pointer
// type (or array thereof), it is a non-POD type and its
// default constructor (if any), copy constructor, move constructor,
// copy assignment operator, move assignment operator, and destructor are
// non-trivial.
setHasObjectMember(true);
struct DefinitionData &Data = data();
Data.PlainOldData = false;
Data.HasTrivialSpecialMembers = 0;
Data.HasIrrelevantDestructor = false;
} else if (!Context.getLangOpts().ObjCAutoRefCount) {
setHasObjectMember(true);
}
================
Comment at: lib/Sema/SemaDeclCXX.cpp:4407
+ (SemaRef.getLangOpts().ObjCWeak &&
+ FieldBaseElementType.getObjCLifetime() == Qualifiers::OCL_Weak))) {
+ // ARC and Weak:
----------------
I think this entire check can just be:
if (FieldBaseElementType.hasNonTrivialObjCLifetime())
The language-options checks are almost certainly slower than just checking the qualifiers.
https://reviews.llvm.org/D31003
More information about the cfe-commits
mailing list