clang should produce the same errors Objective-C classes that cannot be assigned to weak pointers under both -fobjc-arc and -fobjc-weak. Check for ObjCWeak along with ObjCAutoRefCount when analyzing pointer conversions. Add an -fobjc-weak pass to the existing arc-unavailable-for-weakref test cases to verify the behavior is the same.
Details
Diff Detail
Event Timeline
lib/Sema/SemaCast.cpp | ||
---|---|---|
125 | Unlike the other patches, we do clearly need to be checking the language options in places like this. Still, it's a shame to repeat the same condition in a million places. I think the right thing to do here is to add a helper method to LangOpts: /// Returns true if any types in the program might have non-trivial lifetime qualifiers. bool allowsNonTrivialObjCLifetimeQualifiers() const { return ObjCAutoRefCount || ObjCWeak; } |
lib/Sema/SemaCast.cpp | ||
---|---|---|
125 | Thanks for the suggestion. I was hesitant to add a method to LangOpts since it has so few derived state functions, but it certainly makes everything else cleaner. |
LGTM.
lib/Sema/SemaCast.cpp | ||
---|---|---|
125 | There's probably two main reasons for that:
|
Thank you @rjmccall for the approval. I don't have commit access; would someone be willing to commit this path for me please? Thanks!
Unlike the other patches, we do clearly need to be checking the language options in places like this. Still, it's a shame to repeat the same condition in a million places.
I think the right thing to do here is to add a helper method to LangOpts: