Lines Matching refs:property

1 //===--- SemaObjCProperty.cpp - Semantic Analysis for ObjC @property ------===//
9 // This file implements semantic analysis for Objective C @property and
32 /// getImpliedARCOwnership - Given a set of property attributes and a
53 // property type.
62 /// Check the internal consistency of a property declaration with
65 ObjCPropertyDecl *property) {
66 if (property->isInvalidDecl()) return;
68 ObjCPropertyAttribute::Kind propertyKind = property->getPropertyAttributes();
70 = property->getType().getObjCLifetime();
75 = getImpliedARCOwnership(propertyKind, property->getType());
77 // We have a lifetime qualifier but no dominating property
79 // setting the property attribute according to the lifetime
90 property->setPropertyAttributes(attr);
96 property->setInvalidDecl();
97 S.Diag(property->getLocation(),
99 << property->getDeclName()
104 /// Check this Objective-C property against a property declared in the
114 // Look for a property with the same name.
121 // Check this property against any protocols we inherit.
219 // Validate the attributes on the @property.
230 // For a class, compare the property against a property in our superclass.
244 // Also compare the property against a property in our protocols.
257 // when property in class extension is constructed.
347 // Determine whether the given property is readonly and implicitly
367 // If we're allowed to propagate atomicity, and the new property did
384 // One of the properties is atomic; if it's a readonly property, and
420 // Diagnose if this property is already in continuation class.
425 // We need to look in the @interface to see if the @property was
436 // Find the property in the extended class's primary class or
441 // If we found a property in an extension, complain.
450 // A readonly property declared in the primary class can be refined
451 // by adding a readwrite property within an extension.
455 // property is declared both in the @interface and the continuation.
495 // Take the ownership from the original property.
499 // If the redeclaration is 'weak' but the original property is not,
519 // If there was no declaration of a property with the same name in
529 // Relax the strict type matching for property type in continuation class.
530 // Allow property object type of continuation class to be different as long
531 // as it narrows the object type in its primary class property. Note that
533 // property in primary class and 'narrowed' type for a 'readwrite' property
549 // Check that atomicity of property in class extension matches the previous
589 // Issue a warning if property is 'assign' as default and its
623 // Class property and instance property can have the same name.
722 ObjCPropertyDecl *property,
724 if (property->isInvalidDecl() || ivar->isInvalidDecl()) return;
729 // The lifetime implied by the property's attributes.
731 getImpliedARCOwnership(property->getPropertyAttributes(),
732 property->getType());
747 // property implementation before parsing any method bodies.
764 << property->getDeclName()
771 << property->getDeclName()
777 << property->getDeclName() << ivar->getDeclName()
778 << ((property->getPropertyAttributesAsWritten() &
786 // Any other property should be ignored.
790 S.Diag(property->getLocation(), diag::note_property_declare);
797 /// property with no known lifetime of its own, using backing
798 /// 'ivar's attribute, if any. If no backing 'ivar', property's
801 ObjCPropertyDecl *property, ObjCIvarDecl *ivar) {
803 getImpliedARCOwnership(property->getPropertyAttributes(),
804 property->getType());
809 // if no backing ivar, make property 'strong'.
810 property->setPropertyAttributes(ObjCPropertyAttribute::kind_strong);
813 // property assumes owenership of backing ivar.
817 property->setPropertyAttributes(ObjCPropertyAttribute::kind_strong);
819 property->setPropertyAttributes(ObjCPropertyAttribute::kind_weak);
833 /// property declaration that should be synthesised in all of the inherited
842 "Expected a property from a protocol");
867 // Select the 'readwrite' property if such property exists.
874 // Check that the old property is compatible with the new one.
887 // Represents a property from another protocol that conflicts with the
896 // Verify the property attributes.
904 // The ownership might be incompatible unless the property has no explicit
1013 /// Determine whether any storage attributes were written on the property.
1018 // If this is a readwrite property in a class extension that refines
1019 // a readonly property in the original class definition, check it as
1022 // If it's a readonly property, we're not interested.
1029 // Find the corresponding property in the primary class definition.
1046 /// Create a synthesized property accessor stub inside the \@implementation.
1074 /// builds the AST node for a property implementation declaration; declared
1087 // Make sure we have a context for the property implementation declaration.
1097 ObjCPropertyDecl *property = nullptr;
1099 // Find the class or category class where this property must have
1110 // Look for this property declaration in the @implementation's @interface
1111 property = IDecl->FindPropertyDeclaration(PropertyId, QueryKind);
1112 if (!property) {
1116 if (property->isClassProperty() && Synthesize) {
1120 unsigned PIkind = property->getPropertyAttributesAsWritten();
1127 Diag(property->getLocation(), diag::note_property_declare);
1131 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1134 Diag(property->getLocation(), diag::note_property_declare);
1139 property->hasAttr<IBOutletAttr>() && !AtLoc.isValid()) {
1141 // Search into the class extensions and see if 'readonly property is
1144 DeclContext::lookup_result R = Ext->lookup(property->getDeclName());
1155 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1156 << property;
1159 property->getLParenLoc(), readonlyLoc)) {
1163 Diag(property->getLocation(),
1169 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1170 property = SelectPropertyForSynthesisFromProtocols(*this, AtLoc, IDecl,
1171 property);
1190 // Look for this property declaration in @implementation's category
1191 property = Category->FindPropertyDeclaration(PropertyId, QueryKind);
1192 if (!property) {
1212 QualType PropType = property->getType();
1217 property->getDeclName())) {
1218 Diag(property->getLocation(), diag::note_property_declare);
1223 (property->getPropertyAttributesAsWritten() &
1226 setImpliedPropertyAttributeForReadOnlyProperty(property, Ivar);
1229 ObjCPropertyAttribute::Kind kind = property->getPropertyAttributes();
1233 // Add GC __weak to the ivar type if the property is weak.
1238 Diag(property->getLocation(), diag::note_property_declare);
1245 // the property type.
1254 Diag(property->getLocation(), diag::note_property_declare);
1263 Diag(property->getLocation(),
1275 // Check when default synthesizing a property that there is
1276 // an ivar matching property name and issue warning; since this
1278 // property in non-default synthesis case.
1281 IDecl->lookupInstanceVariable(property->getIdentifier(),
1288 Diag(property->getLocation(), diag::note_property_declare);
1295 // property attributes.
1301 // explicitly write an ownership attribute on the property.
1302 if (!hasWrittenStorageAttribute(property, QueryKind) &&
1306 Diag(property->getLocation(), diag::note_property_declare);
1310 assert(lifetime && "no lifetime for property?");
1327 Diag(property->getLocation(), diag::note_property_declare);
1348 // a property implementation and to avoid future warnings.
1352 << property->getDeclName() << Ivar->getDeclName()
1358 property->setPropertyIvarDecl(Ivar);
1362 // Check that type of property and its ivar are type compatible.
1376 << property->getDeclName() << PropType
1380 // a property implementation and to avoid future warnings.
1385 // specifically for property redeclarations as well as for ivars.
1391 << property->getDeclName() << PropType
1401 << property->getDeclName() << Ivar->getDeclName();
1406 if ((property->getType()->isObjCObjectPointerType() ||
1410 << property->getDeclName() << Ivar->getDeclName();
1416 checkARCPropertyImpl(*this, PropertyLoc, property, Ivar);
1421 assert (property && "ActOnPropertyImplDecl - property declaration missing");
1424 property,
1433 if (ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1478 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1482 Diag(property->getLocation(), diag::note_property_declare);
1498 if (ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1537 if (property->getPropertyAttributes() &
1544 if (property->getType()->isReferenceType()) {
1547 << property->getType();
1577 // use and if 1) property is @dynamic or 2) property is synthesized
1643 // to be overridden by a property with any explicit ownership in the subclass.
1671 // atomic property is 'readonly'.
1695 // FIXME. For future support of covariant property types, revisit this.
1708 bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
1715 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1727 << property->getDeclName() << PropertyRValueType
1742 << property->getDeclName()
1800 // Exclude property for protocols which conform to class's super-class,
1801 // as super-class has to implement the property.
1832 /// an ivar synthesized for 'Method' and 'Method' is a property accessor
1844 // look up a property declaration whose one of its accessors is implemented
1852 // Also look up property declaration in class extension whose one of its
1898 // Is there a matching property synthesize/dynamic?
1929 // Suppress the warning if class's superclass implements property's
1930 // getter and implements property's setter (if readwrite property).
1931 // Or, if property is going to be implemented in its super class.
1944 // If property to be implemented in the super class, ignore.
1970 /* property = */ Prop->getIdentifier(),
2003 // When reporting on missing property setter/getter implementation in
2043 // its primary class (and its super classes) if property is
2099 // Collect property accessors implemented in current implementation.
2119 // Is there a matching property synthesize/dynamic?
2138 const auto *property = propertyImpl->getPropertyDecl();
2143 (property->getPropertyAttributes() &
2145 property->getGetterMethodDecl() && property->getSetterMethodDecl()) {
2155 << setterImpl->getSelector() << property->getDeclName();
2209 // We only care about readwrite atomic property.
2233 // @property () ... case.
2242 //@property id etc.
2278 // Look for a getter explicitly declared alongside the property.
2357 /// AddPropertyAttrs - Propagates attributes from a property to the
2358 /// implicitly-declared getter or setter for that property.
2371 /// have the property type and issue diagnostics if they don't.
2374 void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
2376 ObjCContainerDecl *CD = cast<ObjCContainerDecl>(property->getDeclContext());
2380 bool IsClassProperty = property->isClassProperty();
2382 CD->getClassMethod(property->getGetterName()) :
2383 CD->getInstanceMethod(property->getGetterName());
2391 getClassMethod(property->getGetterName()) :
2393 getInstanceMethod(property->getGetterName());
2396 CD->getClassMethod(property->getSetterName()) :
2397 CD->getInstanceMethod(property->getSetterName());
2402 getClassMethod(property->getSetterName()) :
2404 getInstanceMethod(property->getSetterName());
2405 DiagnosePropertyAccessorMismatch(property, GetterMethod,
2406 property->getLocation());
2413 property->getGetterName(), !IsClassProperty, true, false, CatDecl);
2415 if (ExistingGetter->isDirectMethod() || property->isDirectProperty()) {
2416 Diag(property->getLocation(), diag::err_objc_direct_duplicate_decl)
2417 << property->isDirectProperty() << 1 /* property */
2426 if (!property->isReadOnly() && !SetterMethod) {
2429 property->getSetterName(), !IsClassProperty, true, false, CatDecl);
2431 if (ExistingSetter->isDirectMethod() || property->isDirectProperty()) {
2432 Diag(property->getLocation(), diag::err_objc_direct_duplicate_decl)
2433 << property->isDirectProperty() << 1 /* property */
2442 if (!property->isReadOnly() && SetterMethod) {
2449 property->getType().getNonReferenceType())) {
2450 Diag(property->getLocation(),
2452 << property->getDeclName()
2460 // FIXME: The synthesized property we set here is misleading. We almost always
2465 // No instance/class method of same name as property getter name was found.
2468 SourceLocation Loc = property->getLocation();
2470 // The getter returns the declared property type with all qualifiers
2472 QualType resultTy = property->getType().getAtomicUnqualifiedType();
2474 // If the property is null_resettable, the getter returns nonnull.
2475 if (property->getPropertyAttributes() &
2486 Context, Loc, Loc, property->getGetterName(), resultTy, nullptr, CD,
2490 (property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
2495 AddPropertyAttrs(*this, GetterMethod, property);
2497 if (property->isDirectProperty())
2500 if (property->hasAttr<NSReturnsNotRetainedAttr>())
2504 if (property->hasAttr<ObjCReturnsInnerPointerAttr>())
2508 if (const SectionAttr *SA = property->getAttr<SectionAttr>())
2516 // the property with the same name is seen in the @implementation
2521 property->setGetterMethodDecl(GetterMethod);
2523 // Skip setter if property is read-only.
2524 if (!property->isReadOnly()) {
2527 // No instance/class method of same name as property setter name was
2531 SourceLocation Loc = property->getLocation();
2534 Context, Loc, Loc, property->getSetterName(), Context.VoidTy, nullptr,
2541 (property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
2547 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2549 // If the property is null_resettable, the setter accepts a
2551 if (property->getPropertyAttributes() &
2565 property->getIdentifier(),
2572 AddPropertyAttrs(*this, SetterMethod, property);
2574 if (property->isDirectProperty())
2578 if (const SectionAttr *SA = property->getAttr<SectionAttr>())
2587 // the property with the same name is seen in the @implementation
2592 property->setSetterMethodDecl(SetterMethod);
2598 // @property double bar;
2766 // Warn if user supplied no assignment attribute, property is
2772 // With arc, @property definitions should default to strong when
2783 // Don't issue warning on property with no life time in class
2784 // extension as it is inherited from property in primary class.