diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2014-06-11 21:22:53 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-06-11 21:22:53 +0000 |
| commit | 9c10032c79ca9c1db134962aa5ee882a5f5c98ca (patch) | |
| tree | f1ec03ee2a591ed7a78c70ec19ca4816405fd86f /clang | |
| parent | 2205d4ef052fd6b2c0c75d69a30ea2a16212dff9 (diff) | |
| download | bcm5719-llvm-9c10032c79ca9c1db134962aa5ee882a5f5c98ca.tar.gz bcm5719-llvm-9c10032c79ca9c1db134962aa5ee882a5f5c98ca.zip | |
Objective-C. Accept '__attribute__((__ns_returns_retained__))'
for function/methods returning block in MRR mode as well.
// rdar://17259812
llvm-svn: 210706
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 13 | ||||
| -rw-r--r-- | clang/test/SemaObjC/ns_returns_retained_block_return.m | 18 |
2 files changed, 30 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index da9b8faaa7d..6db2127bd31 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3348,6 +3348,13 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, // Checker-specific attribute handlers. //===----------------------------------------------------------------------===// +static bool isValidSubjectOfNSReturnsRetainedAttribute(Sema &S, QualType type) { + return type->isDependentType() || + type->isObjCObjectPointerType() || + type->isBlockPointerType() || + S.Context.isObjCNSObjectType(type); +} + static bool isValidSubjectOfNSAttribute(Sema &S, QualType type) { return type->isDependentType() || type->isObjCObjectPointerType() || @@ -3412,8 +3419,12 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, bool cf; switch (Attr.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsAutoreleased: case AttributeList::AT_NSReturnsRetained: + typeOK = isValidSubjectOfNSReturnsRetainedAttribute(S, returnType); + cf = false; + break; + + case AttributeList::AT_NSReturnsAutoreleased: case AttributeList::AT_NSReturnsNotRetained: typeOK = isValidSubjectOfNSAttribute(S, returnType); cf = false; diff --git a/clang/test/SemaObjC/ns_returns_retained_block_return.m b/clang/test/SemaObjC/ns_returns_retained_block_return.m new file mode 100644 index 00000000000..b7ce429ffb0 --- /dev/null +++ b/clang/test/SemaObjC/ns_returns_retained_block_return.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fblocks -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s +// expected-no-diagnostics +// rdar://17259812 + +typedef void (^BT) (); + +BT foo() __attribute__((ns_returns_retained)); + +@interface I +BT foo() __attribute__((ns_returns_retained)); +@end + +@implementation I +BT foo() __attribute__((ns_returns_retained)) {return ^{}; } +@end |

