Re: r311443 - [ObjC] Check written attributes only when synthesizing ambiguous property

2017-08-22 Thread Hans Wennborg via cfe-commits
Merged in r311464. Thanks!

On Tue, Aug 22, 2017 at 3:42 AM, Alex L  wrote:
> Hi Hans,
>
> Can you please merge this into LLVM 5? It fixes a rather serious Objective-C
> bug that I introduced just a couple of weeks before the branch.
>
> Cheers,
> Alex
>
>
> On 22 August 2017 at 11:38, Alex Lorenz via cfe-commits
>  wrote:
>>
>> Author: arphaman
>> Date: Tue Aug 22 03:38:07 2017
>> New Revision: 311443
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=311443=rev
>> Log:
>> [ObjC] Check written attributes only when synthesizing ambiguous property
>>
>> This commit fixes a bug introduced in r307903. The attribute ambiguity
>> checker
>> that was introduced in r307903 checked all property attributes, which
>> caused
>> errors for source-compatible properties, like:
>>
>> @property (nonatomic, readonly) NSObject *prop;
>> @property (nonatomic, readwrite) NSObject *prop;
>>
>> because the readwrite property would get implicit 'strong' attribute. The
>> ambiguity checker should be concerned about explicitly specified
>> attributes
>> only.
>>
>> rdar://33748089
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>> cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
>>
>> Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=311443=311442=311443=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Aug 22 03:38:07 2017
>> @@ -872,7 +872,7 @@ SelectPropertyForSynthesisFromProtocols(
>>}
>>
>>QualType RHSType = S.Context.getCanonicalType(Property->getType());
>> -  unsigned OriginalAttributes = Property->getPropertyAttributes();
>> +  unsigned OriginalAttributes =
>> Property->getPropertyAttributesAsWritten();
>>enum MismatchKind {
>>  IncompatibleType = 0,
>>  HasNoExpectedAttribute,
>> @@ -890,7 +890,7 @@ SelectPropertyForSynthesisFromProtocols(
>>SmallVector Mismatches;
>>for (ObjCPropertyDecl *Prop : Properties) {
>>  // Verify the property attributes.
>> -unsigned Attr = Prop->getPropertyAttributes();
>> +unsigned Attr = Prop->getPropertyAttributesAsWritten();
>>  if (Attr != OriginalAttributes) {
>>auto Diag = [&](bool OriginalHasAttribute, StringRef AttributeName)
>> {
>>  MismatchKind Kind = OriginalHasAttribute ? HasNoExpectedAttribute
>>
>> Modified: cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m?rev=311443=311442=311443=diff
>>
>> ==
>> --- cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m (original)
>> +++ cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m Tue Aug 22 03:38:07
>> 2017
>> @@ -225,3 +225,30 @@ __attribute__((objc_root_class))
>>  @implementation TypeVsSetter
>>  @synthesize prop; // expected-note {{property synthesized here}}
>>  @end
>> +
>> +@protocol AutoStrongProp
>> +
>> +@property (nonatomic, readonly) NSObject *prop;
>> +
>> +@end
>> +
>> +@protocol AutoStrongProp_Internal 
>> +
>> +// This property gets the 'strong' attribute automatically.
>> +@property (nonatomic, readwrite) NSObject *prop;
>> +
>> +@end
>> +
>> +@interface SynthesizeWithImplicitStrongNoError : NSObject
>> 
>> +@end
>> +
>> +@interface SynthesizeWithImplicitStrongNoError ()
>> 
>> +
>> +@end
>> +
>> +@implementation SynthesizeWithImplicitStrongNoError
>> +
>> +// no error, 'strong' is implicit in the 'readwrite' property.
>> +@synthesize prop = _prop;
>> +
>> +@end
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r311443 - [ObjC] Check written attributes only when synthesizing ambiguous property

2017-08-22 Thread Alex L via cfe-commits
Hi Hans,

Can you please merge this into LLVM 5? It fixes a rather serious
Objective-C bug that I introduced just a couple of weeks before the branch.

Cheers,
Alex

On 22 August 2017 at 11:38, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Tue Aug 22 03:38:07 2017
> New Revision: 311443
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311443=rev
> Log:
> [ObjC] Check written attributes only when synthesizing ambiguous property
>
> This commit fixes a bug introduced in r307903. The attribute ambiguity
> checker
> that was introduced in r307903 checked all property attributes, which
> caused
> errors for source-compatible properties, like:
>
> @property (nonatomic, readonly) NSObject *prop;
> @property (nonatomic, readwrite) NSObject *prop;
>
> because the readwrite property would get implicit 'strong' attribute. The
> ambiguity checker should be concerned about explicitly specified attributes
> only.
>
> rdar://33748089
>
> Modified:
> cfe/trunk/lib/Sema/SemaObjCProperty.cpp
> cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
>
> Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaO
> bjCProperty.cpp?rev=311443=311442=311443=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Aug 22 03:38:07 2017
> @@ -872,7 +872,7 @@ SelectPropertyForSynthesisFromProtocols(
>}
>
>QualType RHSType = S.Context.getCanonicalType(Property->getType());
> -  unsigned OriginalAttributes = Property->getPropertyAttributes();
> +  unsigned OriginalAttributes = Property->getPropertyAttribute
> sAsWritten();
>enum MismatchKind {
>  IncompatibleType = 0,
>  HasNoExpectedAttribute,
> @@ -890,7 +890,7 @@ SelectPropertyForSynthesisFromProtocols(
>SmallVector Mismatches;
>for (ObjCPropertyDecl *Prop : Properties) {
>  // Verify the property attributes.
> -unsigned Attr = Prop->getPropertyAttributes();
> +unsigned Attr = Prop->getPropertyAttributesAsWritten();
>  if (Attr != OriginalAttributes) {
>auto Diag = [&](bool OriginalHasAttribute, StringRef AttributeName)
> {
>  MismatchKind Kind = OriginalHasAttribute ? HasNoExpectedAttribute
>
> Modified: cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/
> arc-property-decl-attrs.m?rev=311443=311442=311443=diff
> 
> ==
> --- cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m (original)
> +++ cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m Tue Aug 22 03:38:07
> 2017
> @@ -225,3 +225,30 @@ __attribute__((objc_root_class))
>  @implementation TypeVsSetter
>  @synthesize prop; // expected-note {{property synthesized here}}
>  @end
> +
> +@protocol AutoStrongProp
> +
> +@property (nonatomic, readonly) NSObject *prop;
> +
> +@end
> +
> +@protocol AutoStrongProp_Internal 
> +
> +// This property gets the 'strong' attribute automatically.
> +@property (nonatomic, readwrite) NSObject *prop;
> +
> +@end
> +
> +@interface SynthesizeWithImplicitStrongNoError : NSObject
> 
> +@end
> +
> +@interface SynthesizeWithImplicitStrongNoError ()
> 
> +
> +@end
> +
> +@implementation SynthesizeWithImplicitStrongNoError
> +
> +// no error, 'strong' is implicit in the 'readwrite' property.
> +@synthesize prop = _prop;
> +
> +@end
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits