Patch to add semantics check for ObjC2's foreacn statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45561 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp
index bca3ec5..8f340db 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -26,6 +26,20 @@
strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0;
}
+bool Sema::isObjcObjectPointerType(QualType type) const {
+ if (!type->isPointerType() && !type->isObjcQualifiedIdType())
+ return false;
+ if (type == Context.getObjcIdType() || type == Context.getObjcClassType() ||
+ type->isObjcQualifiedIdType())
+ return true;
+
+ while (type->isPointerType()) {
+ PointerType *pointerType = static_cast<PointerType*>(type.getTypePtr());
+ type = pointerType->getPointeeType();
+ }
+ return (type->isObjcInterfaceType() || type->isObjcQualifiedIdType());
+}
+
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
if (PP.getLangOptions().ObjC1) {