aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/CocoaConventions.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
commitc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (patch)
tree27425930fc0c91650a7f3527fcac8e0f92907b90 /lib/Analysis/CocoaConventions.cpp
parent486754660bb926339aefcf012a3f848592babb8b (diff)
downloadsrc-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.tar.gz
src-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.zip
Vendor import of clang trunk r338536:vendor/clang/clang-trunk-r338536
Notes
Notes: svn path=/vendor/clang/dist/; revision=337139 svn path=/vendor/clang/clang-trunk-r338536/; revision=337140; tag=vendor/clang/clang-trunk-r338536
Diffstat (limited to 'lib/Analysis/CocoaConventions.cpp')
-rw-r--r--lib/Analysis/CocoaConventions.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp
index 4d57623e2161..b2d416c171a1 100644
--- a/lib/Analysis/CocoaConventions.cpp
+++ b/lib/Analysis/CocoaConventions.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements cocoa naming convention analysis.
+// This file implements cocoa naming convention analysis.
//
//===----------------------------------------------------------------------===//
@@ -34,15 +34,15 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
return false;
RetTy = TD->getDecl()->getUnderlyingType();
}
-
+
if (Name.empty())
return false;
-
+
// Is the type void*?
const PointerType* PT = RetTy->getAs<PointerType>();
if (!(PT->getPointeeType().getUnqualifiedType()->isVoidType()))
return false;
-
+
// Does the name start with the prefix?
return Name.startswith(Prefix);
}
@@ -66,32 +66,32 @@ bool coreFoundation::isCFObjectRef(QualType T) {
bool cocoa::isCocoaObjectRef(QualType Ty) {
if (!Ty->isObjCObjectPointerType())
return false;
-
+
const ObjCObjectPointerType *PT = Ty->getAs<ObjCObjectPointerType>();
-
+
// Can be true for objects with the 'NSObject' attribute.
if (!PT)
return true;
-
+
// We assume that id<..>, id, Class, and Class<..> all represent tracked
// objects.
if (PT->isObjCIdType() || PT->isObjCQualifiedIdType() ||
PT->isObjCClassType() || PT->isObjCQualifiedClassType())
return true;
-
+
// Does the interface subclass NSObject?
// FIXME: We can memoize here if this gets too expensive.
const ObjCInterfaceDecl *ID = PT->getInterfaceDecl();
-
+
// Assume that anything declared with a forward declaration and no
// @interface subclasses NSObject.
if (!ID->hasDefinition())
return true;
-
+
for ( ; ID ; ID = ID->getSuperClass())
if (ID->getIdentifier()->getName() == "NSObject")
return true;
-
+
return false;
}
@@ -101,11 +101,11 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
const IdentifierInfo *ident = fn->getIdentifier();
if (!ident) return false;
StringRef functionName = ident->getName();
-
+
StringRef::iterator it = functionName.begin();
StringRef::iterator start = it;
StringRef::iterator endI = functionName.end();
-
+
while (true) {
// Scan for the start of 'create' or 'copy'.
for ( ; it != endI ; ++it) {
@@ -124,7 +124,7 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// Did we hit the end of the string? If so, we didn't find a match.
if (it == endI)
return false;
-
+
// Scan for *lowercase* 'reate' or 'opy', followed by no lowercase
// character.
StringRef suffix = functionName.substr(it - start);
@@ -137,10 +137,10 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// Keep scanning.
continue;
}
-
+
if (it == endI || !isLowercase(*it))
return true;
-
+
// If we matched a lowercase character, it isn't the end of the
// word. Keep scanning.
}