[cfe-commits] r125467 - /cfe/trunk/lib/Sema/SemaOverload.cpp
Fariborz Jahanian
fjahanian at apple.com
Sun Feb 13 12:01:48 PST 2011
Author: fjahanian
Date: Sun Feb 13 14:01:48 2011
New Revision: 125467
URL: http://llvm.org/viewvc/llvm-project?rev=125467&view=rev
Log:
Some refactoring and using more modern APIs for
implementation of co/contra-variance objc++
block pointers. // rdar://8979379.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=125467&r1=125466&r2=125467&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Feb 13 14:01:48 2011
@@ -1808,66 +1808,65 @@
const FunctionProtoType *ToFunctionType
= ToPointeeType->getAs<FunctionProtoType>();
- if (FromFunctionType && ToFunctionType) {
- if (Context.getCanonicalType(FromPointeeType)
- == Context.getCanonicalType(ToPointeeType))
- return true;
+ if (!FromFunctionType || !ToFunctionType)
+ return false;
+
+ if (Context.hasSameType(FromPointeeType, ToPointeeType))
+ return true;
- // Perform the quick checks that will tell us whether these
- // function types are obviously different.
- if (FromFunctionType->getNumArgs() != ToFunctionType->getNumArgs() ||
- FromFunctionType->isVariadic() != ToFunctionType->isVariadic() ||
- FromFunctionType->getTypeQuals() != ToFunctionType->getTypeQuals())
- return false;
+ // Perform the quick checks that will tell us whether these
+ // function types are obviously different.
+ if (FromFunctionType->getNumArgs() != ToFunctionType->getNumArgs() ||
+ FromFunctionType->isVariadic() != ToFunctionType->isVariadic())
+ return false;
- bool IncompatibleObjC = false;
- if (Context.getCanonicalType(FromFunctionType->getResultType())
- == Context.getCanonicalType(ToFunctionType->getResultType())) {
- // Okay, the types match exactly. Nothing to do.
- } else {
- QualType RHS = FromFunctionType->getResultType();
- QualType CanRHS = Context.getCanonicalType(RHS);
- QualType LHS = ToFunctionType->getResultType();
- QualType CanLHS = Context.getCanonicalType(LHS);
- if (!CanRHS->isRecordType() &&
- !CanRHS.hasQualifiers() && CanLHS.hasQualifiers())
- CanLHS = CanLHS.getUnqualifiedType();
-
- if (Context.getCanonicalType(CanRHS)
- == Context.getCanonicalType(CanLHS)) {
- // OK exact match.
- } else if (isObjCPointerConversion(CanRHS, CanLHS,
- ConvertedType, IncompatibleObjC)) {
- if (IncompatibleObjC)
- return false;
- // Okay, we have an Objective-C pointer conversion.
- }
- else
- return false;
- }
+ FunctionType::ExtInfo FromEInfo = FromFunctionType->getExtInfo();
+ FunctionType::ExtInfo ToEInfo = ToFunctionType->getExtInfo();
+ if (FromEInfo != ToEInfo)
+ return false;
+
+ bool IncompatibleObjC = false;
+ if (Context.getCanonicalType(FromFunctionType->getResultType())
+ == Context.getCanonicalType(ToFunctionType->getResultType())) {
+ // Okay, the types match exactly. Nothing to do.
+ } else {
+ QualType RHS = FromFunctionType->getResultType();
+ QualType LHS = ToFunctionType->getResultType();
+ if ((!getLangOptions().CPlusPlus || !RHS->isRecordType()) &&
+ !RHS.hasQualifiers() && LHS.hasQualifiers())
+ LHS = LHS.getUnqualifiedType();
+
+ if (Context.hasSameType(RHS,LHS)) {
+ // OK exact match.
+ } else if (isObjCPointerConversion(RHS, LHS,
+ ConvertedType, IncompatibleObjC)) {
+ if (IncompatibleObjC)
+ return false;
+ // Okay, we have an Objective-C pointer conversion.
+ }
+ else
+ return false;
+ }
- // Check argument types.
- for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumArgs();
- ArgIdx != NumArgs; ++ArgIdx) {
- IncompatibleObjC = false;
- QualType FromArgType = FromFunctionType->getArgType(ArgIdx);
- QualType ToArgType = ToFunctionType->getArgType(ArgIdx);
- if (Context.getCanonicalType(FromArgType)
- == Context.getCanonicalType(ToArgType)) {
- // Okay, the types match exactly. Nothing to do.
- } else if (isObjCPointerConversion(ToArgType, FromArgType,
- ConvertedType, IncompatibleObjC)) {
- if (IncompatibleObjC)
- return false;
- // Okay, we have an Objective-C pointer conversion.
- } else
- // Argument types are too different. Abort.
- return false;
- }
- ConvertedType = ToType;
- return true;
- }
- return false;
+ // Check argument types.
+ for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumArgs();
+ ArgIdx != NumArgs; ++ArgIdx) {
+ IncompatibleObjC = false;
+ QualType FromArgType = FromFunctionType->getArgType(ArgIdx);
+ QualType ToArgType = ToFunctionType->getArgType(ArgIdx);
+ if (Context.hasSameType(FromArgType, ToArgType)) {
+ // Okay, the types match exactly. Nothing to do.
+ } else if (isObjCPointerConversion(ToArgType, FromArgType,
+ ConvertedType, IncompatibleObjC)) {
+ if (IncompatibleObjC)
+ return false;
+ // Okay, we have an Objective-C pointer conversion.
+ } else
+ // Argument types are too different. Abort.
+ return false;
+ }
+ ConvertedType = ToType;
+ return true;
}
/// FunctionArgTypesAreEqual - This routine checks two function proto types
More information about the cfe-commits
mailing list