When ARC is enabled in Objective-C++, comparisons between a pointer and Objective-C object pointer typically result in errors like this: invalid operands to a binary expression. This error message can be quite confusing as it doesn't provide a solution to the problem, unlike the non-C++ diagnostic: implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast (it also provides fix-its). This patch forces comparisons between pointers and objective-c object pointers in ARC to use the Objective-C semantic rules to ensure that a better diagnostic is reported.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Sema/SemaExpr.cpp | ||
---|---|---|
9431 | It wasn't clear to me why the code has to be added to the right hand side of the >= operator. Is it equivalent to adding the following code, which I think is easier to understand? I'm assuming you are trying to avoid executing the statement when ObjCAutoRefCount is true and either LHSType or RHSType is an objc pointer type. && (!LangOpts.ObjCAutoRefCount || (!LHSType->isObjCObjectPointerType() && !RHSType->isObjCObjectPointerType())) |
lib/Sema/SemaExpr.cpp | ||
---|---|---|
9431 | Yes, that's correct. I think a more clear condition would be better here, I agree. |
It wasn't clear to me why the code has to be added to the right hand side of the >= operator.
Is it equivalent to adding the following code, which I think is easier to understand? I'm assuming you are trying to avoid executing the statement when ObjCAutoRefCount is true and either LHSType or RHSType is an objc pointer type.