Several cleanups:
- rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect.
- add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time.
- move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64385 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 4ac7214..8c3a0a9 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2256,9 +2256,9 @@
} else if (LHSIface && RHSIface &&
Context.canAssignObjCInterfaces(RHSIface, LHSIface)) {
compositeType = rexT;
- } else if (Context.isObjCIdType(lhptee) ||
- Context.isObjCIdType(rhptee)) {
- // FIXME: This code looks wrong, because isObjCIdType checks
+ } else if (Context.isObjCIdStructType(lhptee) ||
+ Context.isObjCIdStructType(rhptee)) {
+ // FIXME: This code looks wrong, because isObjCIdStructType checks
// the struct but getObjCIdType returns the pointer to
// struct. This is horrible and should be fixed.
compositeType = Context.getObjCIdType();
@@ -2412,9 +2412,9 @@
return ConvTy;
// ID acts sort of like void* for ObjC interfaces
- if (LHSIface && Context.isObjCIdType(rhptee))
+ if (LHSIface && Context.isObjCIdStructType(rhptee))
return ConvTy;
- if (RHSIface && Context.isObjCIdType(lhptee))
+ if (RHSIface && Context.isObjCIdStructType(lhptee))
return ConvTy;
// C99 6.5.16.1p1 (constraint 3): both operands are pointers to qualified or
@@ -2903,21 +2903,6 @@
return lex->getType();
}
-static bool areComparableObjCInterfaces(QualType LHS, QualType RHS,
- ASTContext& Context) {
- const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType();
- const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType();
- // ID acts sort of like void* for ObjC interfaces
- if (LHSIface && Context.isObjCIdType(RHS))
- return true;
- if (RHSIface && Context.isObjCIdType(LHS))
- return true;
- if (!LHSIface || !RHSIface)
- return false;
- return Context.canAssignObjCInterfaces(LHSIface, RHSIface) ||
- Context.canAssignObjCInterfaces(RHSIface, LHSIface);
-}
-
// C99 6.5.8
QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
bool isRelational) {
@@ -2977,7 +2962,7 @@
!LCanPointeeTy->isVoidType() && !RCanPointeeTy->isVoidType() &&
!Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType()) &&
- !areComparableObjCInterfaces(LCanPointeeTy, RCanPointeeTy, Context)) {
+ !Context.areComparableObjCPointerTypes(lType, rType)) {
Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
}
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 32ff7ff..7629987 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -485,11 +485,11 @@
// Allow id<P..> and an 'id' or void* type in all cases.
if (const PointerType *PT = lhs->getAsPointerType()) {
QualType PointeeTy = PT->getPointeeType();
- if (Context.isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
+ if (Context.isObjCIdStructType(PointeeTy) || PointeeTy->isVoidType())
return true;
} else if (const PointerType *PT = rhs->getAsPointerType()) {
QualType PointeeTy = PT->getPointeeType();
- if (Context.isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
+ if (Context.isObjCIdStructType(PointeeTy) || PointeeTy->isVoidType())
return true;
}
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index c96fec7..049aca5 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1019,8 +1019,8 @@
// Objective C++: We're able to convert between "id" and a pointer
// to any interface (in both directions).
- if ((FromIface && Context.isObjCIdType(ToPointeeType))
- || (ToIface && Context.isObjCIdType(FromPointeeType))) {
+ if ((FromIface && Context.isObjCIdStructType(ToPointeeType))
+ || (ToIface && Context.isObjCIdStructType(FromPointeeType))) {
ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
@@ -1029,10 +1029,10 @@
// Objective C++: Allow conversions between the Objective-C "id" and
// "Class", in either direction.
- if ((Context.isObjCIdType(FromPointeeType) &&
- Context.isObjCClassType(ToPointeeType)) ||
- (Context.isObjCClassType(FromPointeeType) &&
- Context.isObjCIdType(ToPointeeType))) {
+ if ((Context.isObjCIdStructType(FromPointeeType) &&
+ Context.isObjCClassStructType(ToPointeeType)) ||
+ (Context.isObjCClassStructType(FromPointeeType) &&
+ Context.isObjCIdStructType(ToPointeeType))) {
ConvertedType = ToType;
return true;
}
@@ -1131,10 +1131,10 @@
// Objective-C++ conversions are always okay.
// FIXME: We should have a different class of conversions for
// the Objective-C++ implicit conversions.
- if (Context.isObjCIdType(FromPointeeType) ||
- Context.isObjCIdType(ToPointeeType) ||
- Context.isObjCClassType(FromPointeeType) ||
- Context.isObjCClassType(ToPointeeType))
+ if (Context.isObjCIdStructType(FromPointeeType) ||
+ Context.isObjCIdStructType(ToPointeeType) ||
+ Context.isObjCClassStructType(FromPointeeType) ||
+ Context.isObjCClassStructType(ToPointeeType))
return false;
if (FromPointeeType->isRecordType() &&