After examining the remaining uses of LangOptions.ObjCAutoRefCount, found a some additional places to also check for ObjCWeak not covered by previous test cases. Added a test file to verify all the code paths that were changed.
Details
Diff Detail
Event Timeline
Same thing about parts of this patch — please try to just check T.hasNonTrivialObjCLifetime() when reasonable.
Thank you for all this, by the way. :)
lib/AST/Type.cpp | ||
---|---|---|
3773 ↗ | (On Diff #92220) | Is this method not identical in behavior to hasNonTrivialObjCLifetime()? |
lib/AST/Type.cpp | ||
---|---|---|
3773 ↗ | (On Diff #92220) | Yes, but I didn't see how to extract that information, which is on the internal QualType. But after examining the usage of this function in SemaInit.cpp:6681, I think we need something similar to the isObjCLifetimeType() implementation above. |
lib/Sema/SemaInit.cpp | ||
---|---|---|
6676–6677 | 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. |
Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks!
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.