diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-06 20:48:48 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-06 20:48:48 +0000 |
commit | 7263feeb367ab55af7e9a6fd701148b1b8264dba (patch) | |
tree | 2c55204894f19e17eaa9d48e6b9aa1d8aa509b89 | |
parent | 24c9db6f367a6143be953b1b9a910aab2141fdff (diff) |
Some code cleanup of r134522
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134529 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclObjC.h | 12 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 9 |
2 files changed, 13 insertions, 8 deletions
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<ArcWeakrefUnavailableAttr>()) + 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<ReferenceType>()->getPointeeType(); - } while (const PointerType *ptr = T->getAs<PointerType>()) T = ptr->getPointeeType(); if (const ObjCObjectPointerType *ObjT = T->getAs<ObjCObjectPointerType>()) { ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl(); - while (Class) { - if (Class->hasAttr<ArcWeakrefUnavailableAttr>()) { + 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(); } } } |