[PATCH] D31007: [Objective-C] Miscellaneous -fobjc-weak Fixes
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 24 09:13:48 PDT 2017
rjmccall added inline comments.
================
Comment at: lib/Sema/SemaInit.cpp:6681
// full-expression's cleanups.
- if ((S.getLangOpts().ObjCAutoRefCount &&
- MTE->getType()->isObjCLifetimeType()) ||
+ if (MTE->getType()->isNonTrivialObjCLifetimeType() ||
(MTE->getStorageDuration() == SD_Automatic &&
----------------
Oh, I see what's happening here. The special case for ARC is actually wholly unnecessary. The code's been written as if MTE->getType() for an ARC temporary will just have type "id". In fact, it'll have a lifetime-qualified type, dependent on the type of the reference which has been bound to it. So we need to mark that there's a temporary cleanup if the type has non-trivial lifetime, i.e. if MTE->getType().hasNonTrivialObjCLifetime(); but this is already considered as part of MTE->getType().isDestructedType(), and the storage-duration condition there is correct as well. So really we should just delete this entire clause.
That should eliminate the need for Type::isNonTrivialObjCLifetimeType(). In general, we don't want methods like that to ever exist: lifetime is determined by qualifiers, and querying a Type instead of a QualType has the potential to implicitly remove qualifiers.
https://reviews.llvm.org/D31007
More information about the cfe-commits
mailing list