diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-03 21:06:18 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-03 21:06:18 +0000 | 
| commit | 5e5998f014a2d1ff81e2b164b902385a4cfbfe98 (patch) | |
| tree | b493df0aa1bbf71db709dbd28ab06bfc319e1741 /clang/lib/Sema/SemaOverload.cpp | |
| parent | e3a172603421e44b8615ebaa5165e3de7f46c85b (diff) | |
| download | bcm5719-llvm-5e5998f014a2d1ff81e2b164b902385a4cfbfe98.tar.gz bcm5719-llvm-5e5998f014a2d1ff81e2b164b902385a4cfbfe98.zip | |
For the sake of Objective-c++ overload resolution,
treat argument types of objective-c pointer types
which only differ in their protocol qualifiers as
the same type (radar 7925668).
llvm-svn: 102955
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 44 | 
1 files changed, 42 insertions, 2 deletions
| diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 2a2521a32c2..21f2a51040e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -374,8 +374,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old) {    if (OldQType != NewQType &&        (OldType->getNumArgs() != NewType->getNumArgs() ||         OldType->isVariadic() != NewType->isVariadic() || -       !std::equal(OldType->arg_type_begin(), OldType->arg_type_end(), -                   NewType->arg_type_begin()))) +       !FunctionArgTypesAreEqual(OldType, NewType)))      return true;    // C++ [temp.over.link]p4: @@ -1332,6 +1331,47 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,    return false;  } +  +/// FunctionArgTypesAreEqual - This routine checks two function proto types +/// for equlity of their argument types. Caller has already checked that +/// they have same number of arguments. This routine assumes that Objective-C +/// pointer types which only differ in their protocol qualifiers are equal. +bool Sema::FunctionArgTypesAreEqual(FunctionProtoType*  OldType,  +                            FunctionProtoType*  NewType){ +  if (!getLangOptions().ObjC1) +    return std::equal(OldType->arg_type_begin(), OldType->arg_type_end(), +                      NewType->arg_type_begin()); +   +  for (FunctionProtoType::arg_type_iterator O = OldType->arg_type_begin(), +       N = NewType->arg_type_begin(), +       E = OldType->arg_type_end(); O && (O != E); ++O, ++N) { +    QualType ToType = (*O); +    QualType FromType = (*N); +    if (ToType != FromType) { +      if (const PointerType *PTTo = ToType->getAs<PointerType>()) { +        if (const PointerType *PTFr = FromType->getAs<PointerType>()) +          if (PTTo->getPointeeType()->isObjCQualifiedIdType() &&  +              PTFr->getPointeeType()->isObjCQualifiedIdType() || +              PTTo->getPointeeType()->isObjCQualifiedClassType() &&  +              PTFr->getPointeeType()->isObjCQualifiedClassType()) +            continue; +      } +      else if (ToType->isObjCObjectPointerType() && +               FromType->isObjCObjectPointerType()) { +        QualType ToInterfaceTy = ToType->getPointeeType(); +        QualType FromInterfaceTy = FromType->getPointeeType(); +        if (const ObjCInterfaceType *OITTo = +            ToInterfaceTy->getAs<ObjCInterfaceType>()) +          if (const ObjCInterfaceType *OITFr = +              FromInterfaceTy->getAs<ObjCInterfaceType>()) +            if (OITTo->getDecl() == OITFr->getDecl()) +              continue; +      } +      return false;   +    } +  } +  return true; +}  /// CheckPointerConversion - Check the pointer conversion from the  /// expression From to the type ToType. This routine checks for | 

