aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-24 23:58:27 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-24 23:58:27 +0000
commitb6ccaac65ca72f72954eb3893bbd940bedd23f00 (patch)
treeb864371d60722f6ca98fa6640505af357ae89878 /lib
parentffceb4ce42d3621025950dc5762cc213fab275d2 (diff)
Move isObjCObjectPointerType() from Sema to ASTContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp26
-rw-r--r--lib/Sema/Sema.cpp21
-rw-r--r--lib/Sema/Sema.h6
-rw-r--r--lib/Sema/SemaStmt.cpp4
4 files changed, 28 insertions, 29 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index fa12364c52..54cc8e0068 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1500,6 +1500,32 @@ void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) {
ObjCConstantStringType = getObjCInterfaceType(Decl);
}
+
+//===----------------------------------------------------------------------===//
+// Type Predicates.
+//===----------------------------------------------------------------------===//
+
+/// isObjCObjectPointerType - Returns true if type is an Objective-C pointer
+/// to an object type. This includes "id" and "Class" (two 'special' pointers
+/// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified
+/// ID type).
+bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
+ if (Ty->isObjCQualifiedIdType())
+ return true;
+
+ if (!Ty->isPointerType())
+ return false;
+
+ // Check to see if this is 'id' or 'Class', both of which are typedefs for
+ // pointer types. This looks for the typedef specifically, not for the
+ // underlying type.
+ if (Ty == getObjCIdType() || Ty == getObjCClassType())
+ return true;
+
+ // If this a pointer to an interface (e.g. NSString*), it is ok.
+ return Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType();
+}
+
//===----------------------------------------------------------------------===//
// Type Compatibility Testing
//===----------------------------------------------------------------------===//
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 32c769b64d..e2986a87a5 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -26,27 +26,6 @@ bool Sema::isBuiltinObjCType(TypedefDecl *TD) {
strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0;
}
-/// isObjCObjectPointerType - Returns true if type is an Objective-C pointer
-/// to an object type. This includes "id" and "Class" (two 'special' pointers
-/// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified
-/// ID type).
-bool Sema::isObjCObjectPointerType(QualType Ty) const {
- if (Ty->isObjCQualifiedIdType())
- return true;
-
- if (!Ty->isPointerType())
- return false;
-
- // Check to see if this is 'id' or 'Class', both of which are typedefs for
- // pointer types. This looks for the typedef specifically, not for the
- // underlying type.
- if (Ty == Context.getObjCIdType() || Ty == Context.getObjCClassType())
- return true;
-
- // If this a pointer to an interface (e.g. NSString*), it is ok.
- return Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType();
-}
-
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
CurContext = Context.getTranslationUnitDecl();
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index d34e7f3740..b87008256a 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -344,12 +344,6 @@ private:
/// isBuiltinObjCType - Returns true of the type is "id", "SEL", "Class"
/// or "Protocol".
bool isBuiltinObjCType(TypedefDecl *TD);
-
- /// isObjCObjectPointerType - Returns true if type is an Objective-C pointer
- /// to an object type. This includes "id" and "Class" (two 'special' pointers
- /// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified
- /// ID type).
- bool isObjCObjectPointerType(QualType type) const;
/// AddInstanceMethodToGlobalPool - All instance methods in a translation
/// unit are added to a global pool. This allows us to efficiently associate
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 5b2da08784..1462d3d57c 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -563,14 +563,14 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
return Diag(D->getLocation(), diag::err_toomany_element_decls);
} else
FirstType = static_cast<Expr*>(first)->getType();
- if (!isObjCObjectPointerType(FirstType))
+ if (!Context.isObjCObjectPointerType(FirstType))
Diag(ForLoc, diag::err_selector_element_type,
FirstType.getAsString(), First->getSourceRange());
}
if (Second) {
DefaultFunctionArrayConversion(Second);
QualType SecondType = Second->getType();
- if (!isObjCObjectPointerType(SecondType))
+ if (!Context.isObjCObjectPointerType(SecondType))
Diag(ForLoc, diag::err_collection_expr_type,
SecondType.getAsString(), Second->getSourceRange());
}