diff options
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 9198bf71cd..bd9279fb50 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2390,6 +2390,22 @@ bool ASTContext::isObjCObjectPointerType(QualType Ty) const { return isObjCNSObjectType(Ty); } +/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's +/// garbage collection attribute. +/// +QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const { + QualType::GCAttrTypes attr = QualType::GCNone; + if (getLangOptions().ObjC1 && + getLangOptions().getGCMode() != LangOptions::NonGC) { + attr = Ty.getObjCGCAttr(); + // Default behavious under objective-c's gc is for objective-c pointers + // be treated as though they were declared as __strong. + if (attr == QualType::GCNone && isObjCObjectPointerType(Ty)) + attr = QualType::Strong; + } + return attr; +} + //===----------------------------------------------------------------------===// // Type Compatibility Testing //===----------------------------------------------------------------------===// |