forked from OSchip/llvm-project
ObjectiveC arc: Move check for type conversions in arc
out of ImpCastExprToType and to the caller site as appropriate. This is in prep. to do more work for // rdar://14569171 llvm-svn: 187503
This commit is contained in:
parent
ec99382b54
commit
374089e7b8
|
@ -284,9 +284,6 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
|
||||||
if (ExprTy == TypeTy)
|
if (ExprTy == TypeTy)
|
||||||
return Owned(E);
|
return Owned(E);
|
||||||
|
|
||||||
if (getLangOpts().ObjCAutoRefCount)
|
|
||||||
CheckObjCARCConversion(SourceRange(), Ty, E, CCK);
|
|
||||||
|
|
||||||
// If this is a derived-to-base cast to a through a virtual base, we
|
// If this is a derived-to-base cast to a through a virtual base, we
|
||||||
// need a vtable.
|
// need a vtable.
|
||||||
if (Kind == CK_DerivedToBase &&
|
if (Kind == CK_DerivedToBase &&
|
||||||
|
|
|
@ -6443,9 +6443,13 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS,
|
||||||
// so that we can use references in built-in functions even in C.
|
// so that we can use references in built-in functions even in C.
|
||||||
// The getNonReferenceType() call makes sure that the resulting expression
|
// The getNonReferenceType() call makes sure that the resulting expression
|
||||||
// does not have reference type.
|
// does not have reference type.
|
||||||
if (result != Incompatible && RHS.get()->getType() != LHSType)
|
if (result != Incompatible && RHS.get()->getType() != LHSType) {
|
||||||
RHS = ImpCastExprToType(RHS.take(),
|
QualType Ty = LHSType.getNonLValueExprType(Context);
|
||||||
LHSType.getNonLValueExprType(Context), Kind);
|
Expr *E = RHS.take();
|
||||||
|
if (getLangOpts().ObjCAutoRefCount)
|
||||||
|
CheckObjCARCConversion(SourceRange(), Ty, E, CCK_ImplicitConversion);
|
||||||
|
RHS = ImpCastExprToType(E, Ty, Kind);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7698,12 +7702,20 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
|
||||||
diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
|
diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
|
||||||
/*isError*/false);
|
/*isError*/false);
|
||||||
}
|
}
|
||||||
if (LHSIsNull && !RHSIsNull)
|
if (LHSIsNull && !RHSIsNull) {
|
||||||
LHS = ImpCastExprToType(LHS.take(), RHSType,
|
Expr *E = LHS.take();
|
||||||
|
if (getLangOpts().ObjCAutoRefCount)
|
||||||
|
CheckObjCARCConversion(SourceRange(), RHSType, E, CCK_ImplicitConversion);
|
||||||
|
LHS = ImpCastExprToType(E, RHSType,
|
||||||
RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
|
RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
|
||||||
else
|
}
|
||||||
RHS = ImpCastExprToType(RHS.take(), LHSType,
|
else {
|
||||||
|
Expr *E = RHS.take();
|
||||||
|
if (getLangOpts().ObjCAutoRefCount)
|
||||||
|
CheckObjCARCConversion(SourceRange(), LHSType, E, CCK_ImplicitConversion);
|
||||||
|
RHS = ImpCastExprToType(E, LHSType,
|
||||||
LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
|
LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
|
||||||
|
}
|
||||||
return ResultTy;
|
return ResultTy;
|
||||||
}
|
}
|
||||||
if (LHSType->isObjCObjectPointerType() &&
|
if (LHSType->isObjCObjectPointerType() &&
|
||||||
|
|
|
@ -2765,7 +2765,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
|
||||||
(void) PrepareCastToObjCObjectPointer(E);
|
(void) PrepareCastToObjCObjectPointer(E);
|
||||||
From = E.take();
|
From = E.take();
|
||||||
}
|
}
|
||||||
|
if (getLangOpts().ObjCAutoRefCount)
|
||||||
|
CheckObjCARCConversion(SourceRange(), ToType, From, CCK);
|
||||||
From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
|
From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
|
||||||
.take();
|
.take();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue