[llvm-branch-commits] [cfe-branch] r311464 - Merging r311443:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 22 09:23:20 PDT 2017


Author: hans
Date: Tue Aug 22 09:23:19 2017
New Revision: 311464

URL: http://llvm.org/viewvc/llvm-project?rev=311464&view=rev
Log:
Merging r311443:
------------------------------------------------------------------------
r311443 | arphaman | 2017-08-22 03:38:07 -0700 (Tue, 22 Aug 2017) | 15 lines

[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/branches/release_50/   (props changed)
    cfe/branches/release_50/lib/Sema/SemaObjCProperty.cpp
    cfe/branches/release_50/test/SemaObjC/arc-property-decl-attrs.m

Propchange: cfe/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 22 09:23:19 2017
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:308455,308722,308824,308897,308996,309054,309058,309112-309113,309226,309263,309327,309382-309383,309488,309503,309523,309569,309607,309633,309636,309640,309722,309752,309975,310006,310158,310191,310359,310516,310672,310691-310692,310694,310700,310704,310706,310776,310804,310829,310983,311115,311182
+/cfe/trunk:308455,308722,308824,308897,308996,309054,309058,309112-309113,309226,309263,309327,309382-309383,309488,309503,309523,309569,309607,309633,309636,309640,309722,309752,309975,310006,310158,310191,310359,310516,310672,310691-310692,310694,310700,310704,310706,310776,310804,310829,310983,311115,311182,311443
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_50/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Sema/SemaObjCProperty.cpp?rev=311464&r1=311463&r2=311464&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/release_50/lib/Sema/SemaObjCProperty.cpp Tue Aug 22 09:23:19 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<MismatchingProperty, 4> 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/branches/release_50/test/SemaObjC/arc-property-decl-attrs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/test/SemaObjC/arc-property-decl-attrs.m?rev=311464&r1=311463&r2=311464&view=diff
==============================================================================
--- cfe/branches/release_50/test/SemaObjC/arc-property-decl-attrs.m (original)
+++ cfe/branches/release_50/test/SemaObjC/arc-property-decl-attrs.m Tue Aug 22 09:23:19 2017
@@ -225,3 +225,30 @@ __attribute__((objc_root_class))
 @implementation TypeVsSetter
 @synthesize prop; // expected-note {{property synthesized here}}
 @end
+
+ at protocol AutoStrongProp
+
+ at property (nonatomic, readonly) NSObject *prop;
+
+ at end
+
+ at protocol AutoStrongProp_Internal <AutoStrongProp>
+
+// This property gets the 'strong' attribute automatically.
+ at property (nonatomic, readwrite) NSObject *prop;
+
+ at end
+
+ at interface SynthesizeWithImplicitStrongNoError : NSObject <AutoStrongProp>
+ at end
+
+ at interface SynthesizeWithImplicitStrongNoError () <AutoStrongProp_Internal>
+
+ at end
+
+ at implementation SynthesizeWithImplicitStrongNoError
+
+// no error, 'strong' is implicit in the 'readwrite' property.
+ at synthesize prop = _prop;
+
+ at end




More information about the llvm-branch-commits mailing list