<div dir="ltr">Hi Hans,<div><br></div><div>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.</div><div><br></div><div>Cheers,</div><div>Alex<br><div class="gmail_extra"><br><div class="gmail_quote">On 22 August 2017 at 11:38, Alex Lorenz via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: arphaman<br>
Date: Tue Aug 22 03:38:07 2017<br>
New Revision: 311443<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=311443&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=311443&view=rev</a><br>
Log:<br>
[ObjC] Check written attributes only when synthesizing ambiguous property<br>
<br>
This commit fixes a bug introduced in r307903. The attribute ambiguity checker<br>
that was introduced in r307903 checked all property attributes, which caused<br>
errors for source-compatible properties, like:<br>
<br>
@property (nonatomic, readonly) NSObject *prop;<br>
@property (nonatomic, readwrite) NSObject *prop;<br>
<br>
because the readwrite property would get implicit 'strong' attribute. The<br>
ambiguity checker should be concerned about explicitly specified attributes<br>
only.<br>
<br>
rdar://33748089<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaObjCPro<wbr>perty.cpp<br>
    cfe/trunk/test/SemaObjC/arc-pr<wbr>operty-decl-attrs.m<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaObjCPro<wbr>perty.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=311443&r1=311442&r2=311443&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaO<wbr>bjCProperty.cpp?rev=311443&r1=<wbr>311442&r2=311443&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaObjCPro<wbr>perty.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaObjCPro<wbr>perty.cpp Tue Aug 22 03:38:07 2017<br>
@@ -872,7 +872,7 @@ SelectPropertyForSynthesisFrom<wbr>Protocols(<br>
   }<br>
<br>
   QualType RHSType = S.Context.getCanonicalType(Pro<wbr>perty->getType());<br>
-  unsigned OriginalAttributes = Property->getPropertyAttribute<wbr>s();<br>
+  unsigned OriginalAttributes = Property->getPropertyAttribute<wbr>sAsWritten();<br>
   enum MismatchKind {<br>
     IncompatibleType = 0,<br>
     HasNoExpectedAttribute,<br>
@@ -890,7 +890,7 @@ SelectPropertyForSynthesisFrom<wbr>Protocols(<br>
   SmallVector<MismatchingProper<wbr>ty, 4> Mismatches;<br>
   for (ObjCPropertyDecl *Prop : Properties) {<br>
     // Verify the property attributes.<br>
-    unsigned Attr = Prop->getPropertyAttributes();<br>
+    unsigned Attr = Prop->getPropertyAttributesAsW<wbr>ritten();<br>
     if (Attr != OriginalAttributes) {<br>
       auto Diag = [&](bool OriginalHasAttribute, StringRef AttributeName) {<br>
         MismatchKind Kind = OriginalHasAttribute ? HasNoExpectedAttribute<br>
<br>
Modified: cfe/trunk/test/SemaObjC/arc-pr<wbr>operty-decl-attrs.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m?rev=311443&r1=311442&r2=311443&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaObjC/<wbr>arc-property-decl-attrs.m?rev=<wbr>311443&r1=311442&r2=311443&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaObjC/arc-pr<wbr>operty-decl-attrs.m (original)<br>
+++ cfe/trunk/test/SemaObjC/arc-pr<wbr>operty-decl-attrs.m Tue Aug 22 03:38:07 2017<br>
@@ -225,3 +225,30 @@ __attribute__((objc_root_class<wbr>))<br>
 @implementation TypeVsSetter<br>
 @synthesize prop; // expected-note {{property synthesized here}}<br>
 @end<br>
+<br>
+@protocol AutoStrongProp<br>
+<br>
+@property (nonatomic, readonly) NSObject *prop;<br>
+<br>
+@end<br>
+<br>
+@protocol AutoStrongProp_Internal <AutoStrongProp><br>
+<br>
+// This property gets the 'strong' attribute automatically.<br>
+@property (nonatomic, readwrite) NSObject *prop;<br>
+<br>
+@end<br>
+<br>
+@interface SynthesizeWithImplicitStrongNo<wbr>Error : NSObject <AutoStrongProp><br>
+@end<br>
+<br>
+@interface SynthesizeWithImplicitStrongNo<wbr>Error () <AutoStrongProp_Internal><br>
+<br>
+@end<br>
+<br>
+@implementation SynthesizeWithImplicitStrongNo<wbr>Error<br>
+<br>
+// no error, 'strong' is implicit in the 'readwrite' property.<br>
+@synthesize prop = _prop;<br>
+<br>
+@end<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div></div>