From: Fariborz Jahanian Date: Wed, 6 Jul 2011 20:48:48 +0000 (+0000) Subject: Some code cleanup of r134522 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7263feeb367ab55af7e9a6fd701148b1b8264dba;p=clang Some code cleanup of r134522 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134529 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 2c12b837bd..a60d2c92f7 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -641,6 +641,18 @@ public: return false; } + /// isArcWeakrefUnavailable - Checks for a class or one of its super classes + /// to be incompatible with __weak references. Returns true if it is. + bool isArcWeakrefUnavailable() const { + const ObjCInterfaceDecl *Class = this; + while (Class) { + if (Class->hasAttr()) + return true; + Class = Class->getSuperClass(); + } + return false; + } + ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared); ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index ae1ccf9886..f9cf630420 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -3212,21 +3212,14 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, // objc_arc_weak_reference_unavailable if (lifetime == Qualifiers::OCL_Weak) { QualType T = type; - if (T->isReferenceType()) { - T = T->getAs()->getPointeeType(); - } while (const PointerType *ptr = T->getAs()) T = ptr->getPointeeType(); if (const ObjCObjectPointerType *ObjT = T->getAs()) { ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl(); - while (Class) { - if (Class->hasAttr()) { + if (Class->isArcWeakrefUnavailable()) { S.Diag(attr.getLoc(), diag::err_arc_unsupported_weak_class); S.Diag(ObjT->getInterfaceDecl()->getLocation(), diag::note_class_declared); - break; - } - Class = Class->getSuperClass(); } } }