forked from OSchip/llvm-project
eliminate getReferencedProtocols from
ObjCQualifiedIdType/ObjCQualifiedInterfaceType, adding an interator interface instead. llvm-svn: 49308
This commit is contained in:
parent
f96084ee73
commit
bd7981a978
|
@ -1087,7 +1087,7 @@ class ObjCQualifiedInterfaceType : public ObjCInterfaceType,
|
||||||
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
|
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
|
||||||
|
|
||||||
ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D,
|
ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D,
|
||||||
ObjCProtocolDecl **Protos, unsigned NumP) :
|
ObjCProtocolDecl **Protos, unsigned NumP) :
|
||||||
ObjCInterfaceType(ObjCQualifiedInterface, D),
|
ObjCInterfaceType(ObjCQualifiedInterface, D),
|
||||||
Protocols(Protos, Protos+NumP) { }
|
Protocols(Protos, Protos+NumP) { }
|
||||||
friend class ASTContext; // ASTContext creates these.
|
friend class ASTContext; // ASTContext creates these.
|
||||||
|
@ -1099,9 +1099,11 @@ public:
|
||||||
unsigned getNumProtocols() const {
|
unsigned getNumProtocols() const {
|
||||||
return Protocols.size();
|
return Protocols.size();
|
||||||
}
|
}
|
||||||
ObjCProtocolDecl **getReferencedProtocols() {
|
|
||||||
return &Protocols[0];
|
typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator;
|
||||||
}
|
qual_iterator qual_begin() const { return Protocols.begin(); }
|
||||||
|
qual_iterator qual_end() const { return Protocols.end(); }
|
||||||
|
|
||||||
virtual void getAsStringInternal(std::string &InnerString) const;
|
virtual void getAsStringInternal(std::string &InnerString) const;
|
||||||
|
|
||||||
void Profile(llvm::FoldingSetNodeID &ID);
|
void Profile(llvm::FoldingSetNodeID &ID);
|
||||||
|
@ -1135,7 +1137,11 @@ public:
|
||||||
}
|
}
|
||||||
ObjCProtocolDecl **getReferencedProtocols() {
|
ObjCProtocolDecl **getReferencedProtocols() {
|
||||||
return &Protocols[0];
|
return &Protocols[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator;
|
||||||
|
qual_iterator qual_begin() const { return Protocols.begin(); }
|
||||||
|
qual_iterator qual_end() const { return Protocols.end(); }
|
||||||
|
|
||||||
virtual void getAsStringInternal(std::string &InnerString) const;
|
virtual void getAsStringInternal(std::string &InnerString) const;
|
||||||
|
|
||||||
|
|
|
@ -811,9 +811,8 @@ QualType ASTContext::getObjCInterfaceType(ObjCInterfaceDecl *Decl) {
|
||||||
return QualType(Decl->TypeForDecl, 0);
|
return QualType(Decl->TypeForDecl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getObjCQualifiedInterfaceType - Return a
|
/// getObjCQualifiedInterfaceType - Return a ObjCQualifiedInterfaceType type for
|
||||||
/// ObjCQualifiedInterfaceType type for the given interface decl and
|
/// the given interface decl and the conforming protocol list.
|
||||||
/// the conforming protocol list.
|
|
||||||
QualType ASTContext::getObjCQualifiedInterfaceType(ObjCInterfaceDecl *Decl,
|
QualType ASTContext::getObjCQualifiedInterfaceType(ObjCInterfaceDecl *Decl,
|
||||||
ObjCProtocolDecl **Protocols, unsigned NumProtocols) {
|
ObjCProtocolDecl **Protocols, unsigned NumProtocols) {
|
||||||
llvm::FoldingSetNodeID ID;
|
llvm::FoldingSetNodeID ID;
|
||||||
|
@ -1443,6 +1442,9 @@ bool ASTContext::objcTypesAreCompatible(QualType LHS, QualType RHS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// areCompatObjCQualInterfaces - Return true if the two qualified interface
|
||||||
|
/// types are compatible for assignment from RHS to LHS.
|
||||||
|
///
|
||||||
static bool
|
static bool
|
||||||
areCompatObjCQualInterfaces(const ObjCQualifiedInterfaceType *LHS,
|
areCompatObjCQualInterfaces(const ObjCQualifiedInterfaceType *LHS,
|
||||||
const ObjCQualifiedInterfaceType *RHS) {
|
const ObjCQualifiedInterfaceType *RHS) {
|
||||||
|
@ -1525,13 +1527,10 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs,
|
||||||
QualType PointeeTy = PT->getPointeeType();
|
QualType PointeeTy = PT->getPointeeType();
|
||||||
if (isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
|
if (isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
|
||||||
return true;
|
return true;
|
||||||
|
} else if (const PointerType *PT = rhs->getAsPointerType()) {
|
||||||
}
|
|
||||||
else if (const PointerType *PT = rhs->getAsPointerType()) {
|
|
||||||
QualType PointeeTy = PT->getPointeeType();
|
QualType PointeeTy = PT->getPointeeType();
|
||||||
if (isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
|
if (isObjCIdType(PointeeTy) || PointeeTy->isVoidType())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCQualifiedInterfaceType *lhsQI = 0;
|
ObjCQualifiedInterfaceType *lhsQI = 0;
|
||||||
|
@ -1558,15 +1557,13 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs,
|
||||||
if (!rhsQI && !rhsQID && !rhsID)
|
if (!rhsQI && !rhsQID && !rhsID)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned numRhsProtocols = 0;
|
ObjCQualifiedIdType::qual_iterator RHSProtoI, RHSProtoE;
|
||||||
ObjCProtocolDecl **rhsProtoList = 0;
|
|
||||||
if (rhsQI) {
|
if (rhsQI) {
|
||||||
numRhsProtocols = rhsQI->getNumProtocols();
|
RHSProtoI = rhsQI->qual_begin();
|
||||||
rhsProtoList = rhsQI->getReferencedProtocols();
|
RHSProtoE = rhsQI->qual_end();
|
||||||
}
|
} else if (rhsQID) {
|
||||||
else if (rhsQID) {
|
RHSProtoI = rhsQID->qual_begin();
|
||||||
numRhsProtocols = rhsQID->getNumProtocols();
|
RHSProtoE = rhsQID->qual_end();
|
||||||
rhsProtoList = rhsQID->getReferencedProtocols();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i =0; i < lhsQID->getNumProtocols(); i++) {
|
for (unsigned i =0; i < lhsQID->getNumProtocols(); i++) {
|
||||||
|
@ -1579,13 +1576,14 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs,
|
||||||
if (rhsID) {
|
if (rhsID) {
|
||||||
if (ClassImplementsProtocol(lhsProto, rhsID, true))
|
if (ClassImplementsProtocol(lhsProto, rhsID, true))
|
||||||
match = true;
|
match = true;
|
||||||
}
|
} else {
|
||||||
else for (unsigned j = 0; j < numRhsProtocols; j++) {
|
for (; RHSProtoI != RHSProtoE; ++RHSProtoI) {
|
||||||
ObjCProtocolDecl *rhsProto = rhsProtoList[j];
|
ObjCProtocolDecl *rhsProto = *RHSProtoI;
|
||||||
if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) ||
|
if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) ||
|
||||||
compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) {
|
compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!match)
|
if (!match)
|
||||||
|
@ -1609,16 +1607,15 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs,
|
||||||
if (!lhsQI && !lhsQID && !lhsID)
|
if (!lhsQI && !lhsQID && !lhsID)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned numLhsProtocols = 0;
|
ObjCQualifiedIdType::qual_iterator LHSProtoI, LHSProtoE;
|
||||||
ObjCProtocolDecl **lhsProtoList = 0;
|
|
||||||
if (lhsQI) {
|
if (lhsQI) {
|
||||||
numLhsProtocols = lhsQI->getNumProtocols();
|
LHSProtoI = lhsQI->qual_begin();
|
||||||
lhsProtoList = lhsQI->getReferencedProtocols();
|
LHSProtoE = lhsQI->qual_end();
|
||||||
|
} else if (lhsQID) {
|
||||||
|
LHSProtoI = lhsQID->qual_begin();
|
||||||
|
LHSProtoE = lhsQID->qual_end();
|
||||||
}
|
}
|
||||||
else if (lhsQID) {
|
|
||||||
numLhsProtocols = lhsQID->getNumProtocols();
|
|
||||||
lhsProtoList = lhsQID->getReferencedProtocols();
|
|
||||||
}
|
|
||||||
bool match = false;
|
bool match = false;
|
||||||
// for static type vs. qualified 'id' type, check that class implements
|
// for static type vs. qualified 'id' type, check that class implements
|
||||||
// one of 'id's protocols.
|
// one of 'id's protocols.
|
||||||
|
@ -1630,16 +1627,17 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else for (unsigned i =0; i < numLhsProtocols; i++) {
|
for (; LHSProtoI != LHSProtoE; ++LHSProtoI) {
|
||||||
match = false;
|
match = false;
|
||||||
ObjCProtocolDecl *lhsProto = lhsProtoList[i];
|
ObjCProtocolDecl *lhsProto = *LHSProtoI;
|
||||||
for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) {
|
for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) {
|
||||||
ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j);
|
ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j);
|
||||||
if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) ||
|
if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) ||
|
||||||
compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) {
|
compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto)) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue