@@ -2119,10 +2119,10 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
2119
2119
if (!InterfaceT.isCanonical () ||
2120
2120
!areSortedAndUniqued (Protocols, NumProtocols)) {
2121
2121
if (!areSortedAndUniqued (Protocols, NumProtocols)) {
2122
- llvm::SmallVector<ObjCProtocolDecl*, 8 > Sorted (NumProtocols);
2122
+ llvm::SmallVector<ObjCProtocolDecl*, 8 > Sorted (Protocols,
2123
+ Protocols + NumProtocols);
2123
2124
unsigned UniqueCount = NumProtocols;
2124
2125
2125
- std::copy (Protocols, Protocols + NumProtocols, Sorted.begin ());
2126
2126
SortAndUniqueProtocols (&Sorted[0 ], UniqueCount);
2127
2127
2128
2128
Canonical = getObjCObjectPointerType (getCanonicalType (InterfaceT),
@@ -2165,8 +2165,8 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
2165
2165
// Sort the protocol list alphabetically to canonicalize it.
2166
2166
QualType Canonical;
2167
2167
if (NumProtocols && !areSortedAndUniqued (Protocols, NumProtocols)) {
2168
- llvm::SmallVector<ObjCProtocolDecl*, 8 > Sorted (NumProtocols);
2169
- std::copy (Protocols, Protocols + NumProtocols, Sorted. begin () );
2168
+ llvm::SmallVector<ObjCProtocolDecl*, 8 > Sorted (Protocols,
2169
+ Protocols + NumProtocols);
2170
2170
2171
2171
unsigned UniqueCount = NumProtocols;
2172
2172
SortAndUniqueProtocols (&Sorted[0 ], UniqueCount);
@@ -2645,14 +2645,9 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) {
2645
2645
2646
2646
QualType ASTContext::getBaseElementType (QualType QT) {
2647
2647
QualifierCollector Qs;
2648
- while (true ) {
2649
- const Type *UT = Qs.strip (QT);
2650
- if (const ArrayType *AT = getAsArrayType (QualType (UT,0 ))) {
2651
- QT = AT->getElementType ();
2652
- } else {
2653
- return Qs.apply (QT);
2654
- }
2655
- }
2648
+ while (const ArrayType *AT = getAsArrayType (QualType (Qs.strip (QT), 0 )))
2649
+ QT = AT->getElementType ();
2650
+ return Qs.apply (QT);
2656
2651
}
2657
2652
2658
2653
QualType ASTContext::getBaseElementType (const ArrayType *AT) {
@@ -3579,12 +3574,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
3579
3574
// Another legacy compatibility encoding. Some ObjC qualifier and type
3580
3575
// combinations need to be rearranged.
3581
3576
// Rewrite "in const" from "nr" to "rn"
3582
- const char * s = S.c_str ();
3583
- int len = S.length ();
3584
- if (len >= 2 && s[len-2 ] == ' n' && s[len-1 ] == ' r' ) {
3585
- std::string replace = " rn" ;
3586
- S.replace (S.end ()-2 , S.end (), replace);
3587
- }
3577
+ if (llvm::StringRef (S).endswith (" nr" ))
3578
+ S.replace (S.end ()-2 , S.end (), " rn" );
3588
3579
}
3589
3580
3590
3581
if (PointeeTy->isCharType ()) {
0 commit comments