[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; ObjCInterfaceDecl *getInterface() const;
typedef ObjCProtocolDecl * const *qual_iterator; 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_begin() const { return getProtocolStorage(); }
qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); } qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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