summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2015-10-22 01:56:18 +0000
committerCraig Topper <craig.topper@gmail.com>2015-10-22 01:56:18 +0000
commit6a8c151ecb1a8438535546fb104fc0e86f9323dc (patch)
tree977adac5347a74981ef565eec114db9021e417d3
parentd8040cfa9f5e62a5e6a0b855727d006392de609d (diff)
downloadbcm5719-llvm-6a8c151ecb1a8438535546fb104fc0e86f9323dc.tar.gz
bcm5719-llvm-6a8c151ecb1a8438535546fb104fc0e86f9323dc.zip
Change SortAndUniqueProtocols to operate directly on a SmallVector rather than taking a pointer and element count that it modifies. This paves the way to directly convert the small vector into an ArrayRef without needing to explicitly pass the modified size. No functional change intended.
While there also use a range-based for loop and use append instead of insert to copy elements into the empty SmallVector." llvm-svn: 250971
-rw-r--r--clang/lib/AST/ASTContext.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 848158877aa..dd47d43ccb1 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3638,20 +3638,18 @@ static bool areSortedAndUniqued(ObjCProtocolDecl * const *Protocols,
return true;
}
-static void SortAndUniqueProtocols(ObjCProtocolDecl **Protocols,
- unsigned &NumProtocols) {
- ObjCProtocolDecl **ProtocolsEnd = Protocols+NumProtocols;
-
+static void
+SortAndUniqueProtocols(SmallVectorImpl<ObjCProtocolDecl *> &Protocols) {
// Sort protocols, keyed by name.
- llvm::array_pod_sort(Protocols, ProtocolsEnd, CmpProtocolNames);
+ llvm::array_pod_sort(Protocols.begin(), Protocols.end(), CmpProtocolNames);
// Canonicalize.
- for (unsigned I = 0, N = NumProtocols; I != N; ++I)
- Protocols[I] = Protocols[I]->getCanonicalDecl();
-
+ for (ObjCProtocolDecl *&P : Protocols)
+ P = P->getCanonicalDecl();
+
// Remove duplicates.
- ProtocolsEnd = std::unique(Protocols, ProtocolsEnd);
- NumProtocols = ProtocolsEnd-Protocols;
+ auto ProtocolsEnd = std::unique(Protocols.begin(), Protocols.end());
+ Protocols.erase(ProtocolsEnd, Protocols.end());
}
QualType ASTContext::getObjCObjectType(QualType BaseType,
@@ -3716,12 +3714,9 @@ QualType ASTContext::getObjCObjectType(
ArrayRef<ObjCProtocolDecl *> canonProtocols;
SmallVector<ObjCProtocolDecl*, 8> canonProtocolsVec;
if (!protocolsSorted) {
- canonProtocolsVec.insert(canonProtocolsVec.begin(),
- protocols.begin(),
- protocols.end());
- unsigned uniqueCount = protocols.size();
- SortAndUniqueProtocols(&canonProtocolsVec[0], uniqueCount);
- canonProtocols = llvm::makeArrayRef(&canonProtocolsVec[0], uniqueCount);
+ canonProtocolsVec.append(protocols.begin(), protocols.end());
+ SortAndUniqueProtocols(canonProtocolsVec);
+ canonProtocols = canonProtocolsVec;
} else {
canonProtocols = protocols;
}
OpenPOWER on IntegriCloud