Simplify some code. No change in functionality.

llvm-svn: 102445
This commit is contained in:
Benjamin Kramer 2010-04-27 17:12:11 +00:00
parent 4423926e66
commit 2e3197e60b
1 changed files with 9 additions and 18 deletions

View File

@ -2119,10 +2119,10 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
if (!InterfaceT.isCanonical() || if (!InterfaceT.isCanonical() ||
!areSortedAndUniqued(Protocols, NumProtocols)) { !areSortedAndUniqued(Protocols, NumProtocols)) {
if (!areSortedAndUniqued(Protocols, NumProtocols)) { if (!areSortedAndUniqued(Protocols, NumProtocols)) {
llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(NumProtocols); llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(Protocols,
Protocols + NumProtocols);
unsigned UniqueCount = NumProtocols; unsigned UniqueCount = NumProtocols;
std::copy(Protocols, Protocols + NumProtocols, Sorted.begin());
SortAndUniqueProtocols(&Sorted[0], UniqueCount); SortAndUniqueProtocols(&Sorted[0], UniqueCount);
Canonical = getObjCObjectPointerType(getCanonicalType(InterfaceT), Canonical = getObjCObjectPointerType(getCanonicalType(InterfaceT),
@ -2165,8 +2165,8 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
// Sort the protocol list alphabetically to canonicalize it. // Sort the protocol list alphabetically to canonicalize it.
QualType Canonical; QualType Canonical;
if (NumProtocols && !areSortedAndUniqued(Protocols, NumProtocols)) { if (NumProtocols && !areSortedAndUniqued(Protocols, NumProtocols)) {
llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(NumProtocols); llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(Protocols,
std::copy(Protocols, Protocols + NumProtocols, Sorted.begin()); Protocols + NumProtocols);
unsigned UniqueCount = NumProtocols; unsigned UniqueCount = NumProtocols;
SortAndUniqueProtocols(&Sorted[0], UniqueCount); SortAndUniqueProtocols(&Sorted[0], UniqueCount);
@ -2645,15 +2645,10 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) {
QualType ASTContext::getBaseElementType(QualType QT) { QualType ASTContext::getBaseElementType(QualType QT) {
QualifierCollector Qs; QualifierCollector Qs;
while (true) { while (const ArrayType *AT = getAsArrayType(QualType(Qs.strip(QT), 0)))
const Type *UT = Qs.strip(QT);
if (const ArrayType *AT = getAsArrayType(QualType(UT,0))) {
QT = AT->getElementType(); QT = AT->getElementType();
} else {
return Qs.apply(QT); return Qs.apply(QT);
} }
}
}
QualType ASTContext::getBaseElementType(const ArrayType *AT) { QualType ASTContext::getBaseElementType(const ArrayType *AT) {
QualType ElemTy = AT->getElementType(); QualType ElemTy = AT->getElementType();
@ -3579,12 +3574,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// Another legacy compatibility encoding. Some ObjC qualifier and type // Another legacy compatibility encoding. Some ObjC qualifier and type
// combinations need to be rearranged. // combinations need to be rearranged.
// Rewrite "in const" from "nr" to "rn" // Rewrite "in const" from "nr" to "rn"
const char * s = S.c_str(); if (llvm::StringRef(S).endswith("nr"))
int len = S.length(); S.replace(S.end()-2, S.end(), "rn");
if (len >= 2 && s[len-2] == 'n' && s[len-1] == 'r') {
std::string replace = "rn";
S.replace(S.end()-2, S.end(), replace);
}
} }
if (PointeeTy->isCharType()) { if (PointeeTy->isCharType()) {