diff options
-rw-r--r-- | include/clang/AST/ASTContext.h | 2 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 42 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 2 |
3 files changed, 26 insertions, 20 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 0abdbb05a5..e497354684 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -945,7 +945,7 @@ public: /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's /// garbage collection attribute. /// - Qualifiers::GC getObjCGCAttrKind(const QualType &Ty) const; + Qualifiers::GC getObjCGCAttrKind(QualType Ty) const; /// areCompatibleVectorTypes - Return true if the given vector types /// are of the same unqualified type or if they are equivalent to the same diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e76238cb22..a64d149d80 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4339,24 +4339,30 @@ bool ASTContext::isObjCNSObjectType(QualType Ty) const { /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's /// garbage collection attribute. /// -Qualifiers::GC ASTContext::getObjCGCAttrKind(const QualType &Ty) const { - Qualifiers::GC GCAttrs = Qualifiers::GCNone; - if (getLangOptions().ObjC1 && - getLangOptions().getGCMode() != LangOptions::NonGC) { - GCAttrs = Ty.getObjCGCAttr(); - // Default behavious under objective-c's gc is for objective-c pointers - // (or pointers to them) be treated as though they were declared - // as __strong. - if (GCAttrs == Qualifiers::GCNone) { - if (Ty->isObjCObjectPointerType() || Ty->isBlockPointerType()) - GCAttrs = Qualifiers::Strong; - else if (Ty->isPointerType()) - return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType()); - } - // Non-pointers have none gc'able attribute regardless of the attribute - // set on them. - else if (!Ty->isAnyPointerType() && !Ty->isBlockPointerType()) - return Qualifiers::GCNone; +Qualifiers::GC ASTContext::getObjCGCAttrKind(QualType Ty) const { + if (getLangOptions().getGCMode() == LangOptions::NonGC) + return Qualifiers::GCNone; + + assert(getLangOptions().ObjC1); + Qualifiers::GC GCAttrs = Ty.getObjCGCAttr(); + + // Default behaviour under objective-C's gc is for ObjC pointers + // (or pointers to them) be treated as though they were declared + // as __strong. + if (GCAttrs == Qualifiers::GCNone) { + if (Ty->isObjCObjectPointerType() || Ty->isBlockPointerType()) + return Qualifiers::Strong; + else if (Ty->isPointerType()) + return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType()); + } else { + // It's not valid to set GC attributes on anything that isn't a + // pointer. +#ifndef NDEBUG + QualType CT = Ty->getCanonicalTypeInternal(); + while (const ArrayType *AT = dyn_cast<ArrayType>(CT)) + CT = AT->getElementType(); + assert(CT->isAnyPointerType() || CT->isBlockPointerType()); +#endif } return GCAttrs; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 2f7c9cf642..ada8a1d8a2 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -310,7 +310,7 @@ distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, case DeclaratorChunk::Pointer: case DeclaratorChunk::BlockPointer: innermost = i; - return; + continue; case DeclaratorChunk::Reference: case DeclaratorChunk::MemberPointer: |