Objective-C: Correctly encode 'retain' and 'copy' for readonly properties.

clang would omit 'C' for 'copy' properties and '&' for 'retain' properties if
the property was also 'readonly'. Fix this, which makes clang match gcc4.2's
behavior.

Fixes PR15928.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nico Weber 2013-05-08 23:47:40 +00:00
Родитель f9ba851c9b
Коммит d7ceab3f31
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -4910,6 +4910,10 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
if (PD->isReadOnly()) {
S += ",R";
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy)
S += ",C";
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain)
S += ",&";
} else {
switch (PD->getSetterKind()) {
case ObjCPropertyDecl::Assign: break;

Просмотреть файл

@ -16,6 +16,10 @@ typedef void (^void_block_t)(void);
@property (copy) void_block_t completionBlock;
@property (retain) PropertyClass* Yblock;
@property (readonly) PropertyClass* readonlyAttr;
@property (readonly,copy) PropertyClass* readonlyCopyAttr;
@property (readonly,retain) PropertyClass* readonlyRetainAttr;
@property (readonly,retain,nonatomic) PropertyClass* readonlyNonatomicAttr;
@property (copy) id ID;
@end
@ -25,6 +29,10 @@ typedef void (^void_block_t)(void);
@dynamic r; // attributes should be "Ti,D"
@synthesize completionBlock=__completion; // "T@?,C,V__completion"
@synthesize Yblock = YVAR; // "T@\"PropertyClass\",&,VYVAR"
@synthesize readonlyAttr;
@synthesize readonlyCopyAttr;
@synthesize readonlyRetainAttr;
@synthesize readonlyNonatomicAttr;
@synthesize ID; // "T@,C,VID"
@end
@ -32,6 +40,10 @@ typedef void (^void_block_t)(void);
// CHECK: Ti,D
// CHECK: T@?,C,V__completion
// CHECK: T@\"PropertyClass\",&,VYVAR
// CHECK: T@\"PropertyClass\",R,VreadonlyAttr
// CHECK: T@\"PropertyClass\",R,C,VreadonlyCopyAttr
// CHECK: T@\"PropertyClass\",R,&,VreadonlyRetainAttr
// CHECK: T@\"PropertyClass\",R,&,N,VreadonlyNonatomicAttr
@interface Test @end
@interface Test (Category)