[C++11] Replacing ObjCObjectType iterators qual_begin() and qual_end() with iterator_range quals(). Updating all of the usages of the iterators with range-based for loops.

llvm-svn: 204047
This commit is contained in:
Aaron Ballman
2014-03-17 15:55:30 +00:00
parent b088fbee3f
commit 1683f7baf6
8 changed files with 20 additions and 36 deletions

View File

@@ -4350,7 +4350,9 @@ public:
ObjCInterfaceDecl *getInterface() const;
typedef ObjCProtocolDecl * const *qual_iterator;
typedef llvm::iterator_range<qual_iterator> qual_range;
qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
qual_iterator qual_begin() const { return getProtocolStorage(); }
qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }

View File

@@ -6706,16 +6706,9 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectType *LHS,
if (SuperClassInheritedProtocols.empty())
return false;
for (ObjCObjectType::qual_iterator LHSPI = LHS->qual_begin(),
LHSPE = LHS->qual_end();
LHSPI != LHSPE; LHSPI++) {
bool SuperImplementsProtocol = false;
ObjCProtocolDecl *LHSProto = (*LHSPI);
for (llvm::SmallPtrSet<ObjCProtocolDecl*,8>::iterator I =
SuperClassInheritedProtocols.begin(),
E = SuperClassInheritedProtocols.end(); I != E; ++I) {
ObjCProtocolDecl *SuperClassProto = (*I);
for (const auto *LHSProto : LHS->quals()) {
bool SuperImplementsProtocol = false;
for (auto *SuperClassProto : SuperClassInheritedProtocols) {
if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
SuperImplementsProtocol = true;
break;
@@ -6729,17 +6722,13 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectType *LHS,
return false;
}
for (ObjCObjectType::qual_iterator LHSPI = LHS->qual_begin(),
LHSPE = LHS->qual_end();
LHSPI != LHSPE; LHSPI++) {
for (const auto *LHSPI : LHS->quals()) {
bool RHSImplementsProtocol = false;
// If the RHS doesn't implement the protocol on the left, the types
// are incompatible.
for (ObjCObjectType::qual_iterator RHSPI = RHS->qual_begin(),
RHSPE = RHS->qual_end();
RHSPI != RHSPE; RHSPI++) {
if ((*RHSPI)->lookupProtocolNamed((*LHSPI)->getIdentifier())) {
for (auto *RHSPI : RHS->quals()) {
if (RHSPI->lookupProtocolNamed(LHSPI->getIdentifier())) {
RHSImplementsProtocol = true;
break;
}

View File

@@ -1780,11 +1780,9 @@ QualType ASTNodeImporter::VisitObjCObjectType(const ObjCObjectType *T) {
return QualType();
SmallVector<ObjCProtocolDecl *, 4> Protocols;
for (ObjCObjectType::qual_iterator P = T->qual_begin(),
PEnd = T->qual_end();
P != PEnd; ++P) {
for (auto *P : T->quals()) {
ObjCProtocolDecl *Protocol
= dyn_cast_or_null<ObjCProtocolDecl>(Importer.Import(*P));
= dyn_cast_or_null<ObjCProtocolDecl>(Importer.Import(P));
if (!Protocol)
return QualType();
Protocols.push_back(Protocol);

View File

@@ -2299,9 +2299,8 @@ void CXXNameMangler::mangleType(const ObjCObjectType *T) {
SmallString<64> QualStr;
llvm::raw_svector_ostream QualOS(QualStr);
QualOS << "objcproto";
ObjCObjectType::qual_iterator i = T->qual_begin(), e = T->qual_end();
for ( ; i != e; ++i) {
StringRef name = (*i)->getName();
for (const auto *I : T->quals()) {
StringRef name = I->getName();
QualOS << name.size() << name;
}
QualOS.flush();

View File

@@ -1259,13 +1259,12 @@ void TypePrinter::printObjCObjectBefore(const ObjCObjectType *T,
print(T->getBaseType(), OS, StringRef());
OS << '<';
bool isFirst = true;
for (ObjCObjectType::qual_iterator
I = T->qual_begin(), E = T->qual_end(); I != E; ++I) {
for (const auto *I : T->quals()) {
if (isFirst)
isFirst = false;
else
OS << ',';
OS << (*I)->getName();
OS << I->getName();
}
OS << '>';
spaceBeforePlaceHolder(OS);

View File

@@ -616,9 +616,8 @@ void Sema::ActOnTypedefedProtocols(SmallVectorImpl<Decl *> &ProtocolRefs,
QualType T = TDecl->getUnderlyingType();
if (T->isObjCObjectType())
if (const ObjCObjectType *OPT = T->getAs<ObjCObjectType>())
for (ObjCObjectType::qual_iterator I = OPT->qual_begin(),
E = OPT->qual_end(); I != E; ++I)
ProtocolRefs.push_back(*I);
for (auto *I : OPT->quals())
ProtocolRefs.push_back(I);
}
}

View File

@@ -1464,9 +1464,8 @@ ObjCMethodDecl *Sema::LookupMethodInObjectType(Selector sel, QualType type,
}
// Check qualifiers.
for (ObjCObjectType::qual_iterator
i = objType->qual_begin(), e = objType->qual_end(); i != e; ++i)
if (ObjCMethodDecl *method = (*i)->lookupMethod(sel, isInstance))
for (const auto *I : objType->quals())
if (ObjCMethodDecl *method = I->lookupMethod(sel, isInstance))
return method;
return 0;

View File

@@ -401,9 +401,8 @@ void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
Writer.AddTypeRef(T->getBaseType(), Record);
Record.push_back(T->getNumProtocols());
for (ObjCObjectType::qual_iterator I = T->qual_begin(),
E = T->qual_end(); I != E; ++I)
Writer.AddDeclRef(*I, Record);
for (const auto *I : T->quals())
Writer.AddDeclRef(I, Record);
Code = TYPE_OBJC_OBJECT;
}