[cfe-commits] r72475 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/Frontend/PCHWriter.cpp lib/Sema/SemaExprObjC.cpp
Steve Naroff
snaroff at apple.com
Wed May 27 09:21:17 PDT 2009
Author: snaroff
Date: Wed May 27 11:21:00 2009
New Revision: 72475
URL: http://llvm.org/viewvc/llvm-project?rev=72475&view=rev
Log:
Convert ObjC qualified type clients over to using iterators.
This allows me to remove some API that I don't want to carry over to ObjCObjectPointerType.
No functionality change.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=72475&r1=72474&r2=72475&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed May 27 11:21:00 2009
@@ -1623,10 +1623,6 @@
/// interface type, or 0 if there are none.
inline unsigned getNumProtocols() const;
- /// getProtocol - Return the specified qualifying protocol.
- inline ObjCProtocolDecl *getProtocol(unsigned i) const;
-
-
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == ObjCInterface ||
@@ -1654,9 +1650,6 @@
friend class ASTContext; // ASTContext creates these.
public:
- ObjCProtocolDecl *getProtocol(unsigned i) const {
- return Protocols[i];
- }
unsigned getNumProtocols() const {
return Protocols.size();
}
@@ -1699,13 +1692,6 @@
return 0;
}
-/// getProtocol - Return the specified qualifying protocol.
-inline ObjCProtocolDecl *ObjCInterfaceType::getProtocol(unsigned i) const {
- return cast<ObjCQualifiedInterfaceType>(this)->getProtocol(i);
-}
-
-
-
/// ObjCQualifiedIdType - to represent id<protocol-list>.
///
/// Duplicate protocols are removed and protocol list is canonicalized to be in
@@ -1723,15 +1709,9 @@
friend class ASTContext; // ASTContext creates these.
public:
- ObjCProtocolDecl *getProtocols(unsigned i) const {
- return Protocols[i];
- }
unsigned getNumProtocols() const {
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(); }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=72475&r1=72474&r2=72475&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed May 27 11:21:00 2009
@@ -2350,10 +2350,10 @@
// Only when doing ivar or property encoding.
const ObjCQualifiedIdType *QIDT = T->getAsObjCQualifiedIdType();
S += '"';
- for (unsigned i =0; i < QIDT->getNumProtocols(); i++) {
- ObjCProtocolDecl *Proto = QIDT->getProtocols(i);
+ for (ObjCQualifiedIdType::qual_iterator I = QIDT->qual_begin(),
+ E = QIDT->qual_end(); I != E; ++I) {
S += '<';
- S += Proto->getNameAsString();
+ S += (*I)->getNameAsString();
S += '>';
}
S += '"';
@@ -2416,10 +2416,10 @@
ObjCInterfaceDecl *OI = OIT->getDecl();
S += '"';
S += OI->getNameAsCString();
- for (unsigned i =0; i < OIT->getNumProtocols(); i++) {
- ObjCProtocolDecl *Proto = OIT->getProtocol(i);
+ for (ObjCInterfaceType::qual_iterator I = OIT->qual_begin(),
+ E = OIT->qual_end(); I != E; ++I) {
S += '<';
- S += Proto->getNameAsString();
+ S += (*I)->getNameAsString();
S += '>';
}
S += '"';
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=72475&r1=72474&r2=72475&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed May 27 11:21:00 2009
@@ -1531,10 +1531,9 @@
InnerString = ' ' + InnerString;
std::string ObjCQIString = "id";
ObjCQIString += '<';
- int num = getNumProtocols();
- for (int i = 0; i < num; i++) {
- ObjCQIString += getProtocols(i)->getNameAsString();
- if (i < num-1)
+ for (qual_iterator I = qual_begin(), E = qual_end(); I != E; ++I) {
+ ObjCQIString += (*I)->getNameAsString();
+ if (I+1 != E)
ObjCQIString += ',';
}
ObjCQIString += '>';
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=72475&r1=72474&r2=72475&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed May 27 11:21:00 2009
@@ -218,15 +218,17 @@
const ObjCQualifiedInterfaceType *T) {
VisitObjCInterfaceType(T);
Record.push_back(T->getNumProtocols());
- for (unsigned I = 0, N = T->getNumProtocols(); I != N; ++I)
- Writer.AddDeclRef(T->getProtocol(I), Record);
+ for (ObjCInterfaceType::qual_iterator I = T->qual_begin(),
+ E = T->qual_end(); I != E; ++I)
+ Writer.AddDeclRef(*I, Record);
Code = pch::TYPE_OBJC_QUALIFIED_INTERFACE;
}
void PCHTypeWriter::VisitObjCQualifiedIdType(const ObjCQualifiedIdType *T) {
Record.push_back(T->getNumProtocols());
- for (unsigned I = 0, N = T->getNumProtocols(); I != N; ++I)
- Writer.AddDeclRef(T->getProtocols(I), Record);
+ for (ObjCQualifiedIdType::qual_iterator I = T->qual_begin(),
+ E = T->qual_end(); I != E; ++I)
+ Writer.AddDeclRef(*I, Record);
Code = pch::TYPE_OBJC_QUALIFIED_ID;
}
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=72475&r1=72474&r2=72475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed May 27 11:21:00 2009
@@ -571,10 +571,11 @@
// We allow sending a message to a qualified ID ("id<foo>"), which is ok as
// long as one of the protocols implements the selector (if not, warn).
- if (ObjCQualifiedIdType *QIT = dyn_cast<ObjCQualifiedIdType>(ReceiverCType)) {
+ if (ObjCQualifiedIdType *QIdTy = dyn_cast<ObjCQualifiedIdType>(ReceiverCType)) {
// Search protocols for instance methods.
- for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
- ObjCProtocolDecl *PDecl = QIT->getProtocols(i);
+ for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(),
+ E = QIdTy->qual_end(); I != E; ++I) {
+ ObjCProtocolDecl *PDecl = *I;
if (PDecl && (Method = PDecl->lookupInstanceMethod(Context, Sel)))
break;
// Since we aren't supporting "Class<foo>", look for a class method.
@@ -750,11 +751,12 @@
// make sure we check the class hierarchy.
if (const ObjCInterfaceType *IT = rtype->getAsObjCInterfaceType()) {
ObjCInterfaceDecl *rhsID = IT->getDecl();
- for (unsigned i = 0; i != lhsQID->getNumProtocols(); ++i) {
+ for (ObjCQualifiedIdType::qual_iterator I = lhsQID->qual_begin(),
+ E = lhsQID->qual_end(); I != E; ++I) {
// when comparing an id<P> on lhs with a static type on rhs,
// see if static class implements all of id's protocols, directly or
// through its super class and categories.
- if (!ClassImplementsProtocol(lhsQID->getProtocols(i), rhsID, true))
+ if (!ClassImplementsProtocol(*I, rhsID, true))
return false;
}
return true;
@@ -773,8 +775,9 @@
return false;
}
- for (unsigned i =0; i < lhsQID->getNumProtocols(); i++) {
- ObjCProtocolDecl *lhsProto = lhsQID->getProtocols(i);
+ for (ObjCQualifiedIdType::qual_iterator I = lhsQID->qual_begin(),
+ E = lhsQID->qual_end(); I != E; ++I) {
+ ObjCProtocolDecl *lhsProto = *I;
bool match = false;
// when comparing an id<P> on lhs with a static type on rhs,
@@ -793,11 +796,12 @@
// make sure we check the class hierarchy.
if (const ObjCInterfaceType *IT = rtype->getAsObjCInterfaceType()) {
ObjCInterfaceDecl *rhsID = IT->getDecl();
- for (unsigned i = 0; i != lhsQID->getNumProtocols(); ++i) {
+ for (ObjCQualifiedIdType::qual_iterator I = lhsQID->qual_begin(),
+ E = lhsQID->qual_end(); I != E; ++I) {
// when comparing an id<P> on lhs with a static type on rhs,
// see if static class implements all of id's protocols, directly or
// through its super class and categories.
- if (ClassImplementsProtocol(lhsQID->getProtocols(i), rhsID, true)) {
+ if (ClassImplementsProtocol(*I, rhsID, true)) {
match = true;
break;
}
@@ -825,8 +829,9 @@
for (; LHSProtoI != LHSProtoE; ++LHSProtoI) {
bool match = false;
ObjCProtocolDecl *lhsProto = *LHSProtoI;
- for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) {
- ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j);
+ for (ObjCQualifiedIdType::qual_iterator I = rhsQID->qual_begin(),
+ E = rhsQID->qual_end(); I != E; ++I) {
+ ObjCProtocolDecl *rhsProto = *I;
if (ProtocolCompatibleWithProtocol(lhsProto, rhsProto) ||
(compare && ProtocolCompatibleWithProtocol(rhsProto, lhsProto))) {
match = true;
@@ -843,9 +848,9 @@
// for static type vs. qualified 'id' type, check that class implements
// all of 'id's protocols.
ObjCInterfaceDecl *lhsID = IT->getDecl();
- for (unsigned j = 0; j < rhsQID->getNumProtocols(); j++) {
- ObjCProtocolDecl *rhsProto = rhsQID->getProtocols(j);
- if (!ClassImplementsProtocol(rhsProto, lhsID, compare, true))
+ for (ObjCQualifiedIdType::qual_iterator I = rhsQID->qual_begin(),
+ E = rhsQID->qual_end(); I != E; ++I) {
+ if (!ClassImplementsProtocol(*I, lhsID, compare, true))
return false;
}
return true;
More information about the cfe-commits
mailing list