aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-27 17:12:11 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-27 17:12:11 +0000
commit0237941e0beb0c929934b66ad29443b484d987fe (patch)
treebcd675220880b5b9a5b8b36b121d483cf5f659e7 /lib/AST/ASTContext.cpp
parentc8fd2dae17a0fc631a07ab7b66c9d3ebe90a0cc6 (diff)
Simplify some code. No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 165105be89..0a39575c43 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2119,10 +2119,10 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
if (!InterfaceT.isCanonical() ||
!areSortedAndUniqued(Protocols, NumProtocols)) {
if (!areSortedAndUniqued(Protocols, NumProtocols)) {
- llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(NumProtocols);
+ llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(Protocols,
+ Protocols + NumProtocols);
unsigned UniqueCount = NumProtocols;
- std::copy(Protocols, Protocols + NumProtocols, Sorted.begin());
SortAndUniqueProtocols(&Sorted[0], UniqueCount);
Canonical = getObjCObjectPointerType(getCanonicalType(InterfaceT),
@@ -2165,8 +2165,8 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
// Sort the protocol list alphabetically to canonicalize it.
QualType Canonical;
if (NumProtocols && !areSortedAndUniqued(Protocols, NumProtocols)) {
- llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(NumProtocols);
- std::copy(Protocols, Protocols + NumProtocols, Sorted.begin());
+ llvm::SmallVector<ObjCProtocolDecl*, 8> Sorted(Protocols,
+ Protocols + NumProtocols);
unsigned UniqueCount = NumProtocols;
SortAndUniqueProtocols(&Sorted[0], UniqueCount);
@@ -2645,14 +2645,9 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) {
QualType ASTContext::getBaseElementType(QualType QT) {
QualifierCollector Qs;
- while (true) {
- const Type *UT = Qs.strip(QT);
- if (const ArrayType *AT = getAsArrayType(QualType(UT,0))) {
- QT = AT->getElementType();
- } else {
- return Qs.apply(QT);
- }
- }
+ while (const ArrayType *AT = getAsArrayType(QualType(Qs.strip(QT), 0)))
+ QT = AT->getElementType();
+ return Qs.apply(QT);
}
QualType ASTContext::getBaseElementType(const ArrayType *AT) {
@@ -3579,12 +3574,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// Another legacy compatibility encoding. Some ObjC qualifier and type
// combinations need to be rearranged.
// Rewrite "in const" from "nr" to "rn"
- const char * s = S.c_str();
- int len = S.length();
- if (len >= 2 && s[len-2] == 'n' && s[len-1] == 'r') {
- std::string replace = "rn";
- S.replace(S.end()-2, S.end(), replace);
- }
+ if (llvm::StringRef(S).endswith("nr"))
+ S.replace(S.end()-2, S.end(), "rn");
}
if (PointeeTy->isCharType()) {