@@ -1881,8 +1881,15 @@ ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType,
1881
1881
return PerformImplicitConversion(From, ToType, ICS, Action);
1882
1882
}
1883
1883
1884
- bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
1885
- QualType &ResultTy) {
1884
+ bool Sema::TryFunctionConversion(QualType FromType, QualType ToType,
1885
+ QualType &ResultTy) const {
1886
+ bool Changed = IsFunctionConversion(FromType, ToType);
1887
+ if (Changed)
1888
+ ResultTy = ToType;
1889
+ return Changed;
1890
+ }
1891
+
1892
+ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
1886
1893
if (Context.hasSameUnqualifiedType(FromType, ToType))
1887
1894
return false;
1888
1895
@@ -1993,7 +2000,6 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
1993
2000
assert(QualType(FromFn, 0).isCanonical());
1994
2001
if (QualType(FromFn, 0) != CanTo) return false;
1995
2002
1996
- ResultTy = ToType;
1997
2003
return true;
1998
2004
}
1999
2005
@@ -2232,11 +2238,10 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
2232
2238
// we can sometimes resolve &foo<int> regardless of ToType, so check
2233
2239
// if the type matches (identity) or we are converting to bool
2234
2240
if (!S.Context.hasSameUnqualifiedType(
2235
- S.ExtractUnqualifiedFunctionType(ToType), FromType)) {
2236
- QualType resultTy;
2241
+ S.ExtractUnqualifiedFunctionType(ToType), FromType)) {
2237
2242
// if the function type matches except for [[noreturn]], it's ok
2238
2243
if (!S.IsFunctionConversion(FromType,
2239
- S.ExtractUnqualifiedFunctionType(ToType), resultTy ))
2244
+ S.ExtractUnqualifiedFunctionType(ToType)))
2240
2245
// otherwise, only a boolean conversion is standard
2241
2246
if (!ToType->isBooleanType())
2242
2247
return false;
@@ -2476,7 +2481,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
2476
2481
// The third conversion can be a function pointer conversion or a
2477
2482
// qualification conversion (C++ [conv.fctptr], [conv.qual]).
2478
2483
bool ObjCLifetimeConversion;
2479
- if (S.IsFunctionConversion (FromType, ToType, FromType)) {
2484
+ if (S.TryFunctionConversion (FromType, ToType, FromType)) {
2480
2485
// Function pointer conversions (removing 'noexcept') including removal of
2481
2486
// 'noreturn' (Clang extension).
2482
2487
SCS.Third = ICK_Function_Conversion;
@@ -5033,7 +5038,6 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
5033
5038
// Check for standard conversions we can apply to pointers: derived-to-base
5034
5039
// conversions, ObjC pointer conversions, and function pointer conversions.
5035
5040
// (Qualification conversions are checked last.)
5036
- QualType ConvertedT2;
5037
5041
if (UnqualT1 == UnqualT2) {
5038
5042
// Nothing to do.
5039
5043
} else if (isCompleteType(Loc, OrigT2) &&
@@ -5044,7 +5048,7 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
5044
5048
Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5045
5049
Conv |= ReferenceConversions::ObjC;
5046
5050
else if (UnqualT2->isFunctionType() &&
5047
- IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2 )) {
5051
+ IsFunctionConversion(UnqualT2, UnqualT1)) {
5048
5052
Conv |= ReferenceConversions::Function;
5049
5053
// No need to check qualifiers; function types don't have them.
5050
5054
return Ref_Compatible;
@@ -13426,9 +13430,8 @@ class AddressOfFunctionResolver {
13426
13430
13427
13431
private:
13428
13432
bool candidateHasExactlyCorrectType(const FunctionDecl *FD) {
13429
- QualType Discard;
13430
13433
return Context.hasSameUnqualifiedType(TargetFunctionType, FD->getType()) ||
13431
- S.IsFunctionConversion(FD->getType(), TargetFunctionType, Discard );
13434
+ S.IsFunctionConversion(FD->getType(), TargetFunctionType);
13432
13435
}
13433
13436
13434
13437
/// \return true if A is considered a better overload candidate for the
0 commit comments