ObjC properties: consider ownership of properties from protocols when synthesizing.

When determining whether ownership was explicitly written for a
property when it is being synthesized, also consider that the original
property might have come from a protocol. Fixes rdar://problem/23931441.

llvm-svn: 255943
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index f42dace..1cb84e4 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -868,6 +868,13 @@
       return OrigProp->getPropertyAttributesAsWritten() & OwnershipMask;
   }
 
+  // Look through all of the protocols.
+  for (const auto *Proto : OrigClass->all_referenced_protocols()) {
+    if (ObjCPropertyDecl *OrigProp =
+          Proto->FindPropertyDeclaration(Prop->getIdentifier()))
+      return OrigProp->getPropertyAttributesAsWritten() & OwnershipMask;
+  }
+
   return false;
 }